zoukankan      html  css  js  c++  java
  • noi.ac NOIP2018 全国热身赛 第二场 T1 ball

    【题解】

      可以发现每次推的操作就是把序列中每个数变为下一个数,再打一个减一标记;而每次加球的操作就是把球的位置加上标记,再插入到合适的位置。

      用set维护即可。

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 #include<set>
     5 #define LL long long
     6 #define rg register
     7 using namespace std;
     8 int n,m,P,cnt;
     9 set<int>s;
    10 inline int read(){
    11     int k=0,f=1; char c=getchar();
    12     while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
    13     while('0'<=c&&c<='9')k=k*10+c-'0',c=getchar();
    14     return k*f;
    15 }
    16 int main(){
    17     n=read(); m=read(); P=read();
    18     for(rg int i=1;i<=n;i++) s.insert(read());
    19     while(m--){
    20         int opt=read();
    21         if(opt==1) s.insert(read()+cnt);
    22         else s.erase(s.begin()),s.insert(P+cnt),cnt++;
    23     }
    24     for(set<int>::iterator it=s.begin();it!=s.end();it++) printf("%d ",*it-cnt);
    25     return 0;
    26 }
  • 相关阅读:
    第二阶段个人冲刺总结01
    软件工程学习进度表13
    软件工程学习进度表12
    个人博客(09)
    个人博客(07)
    个人博客(08)
    poj1562 DFS入门
    poj3278 BFS入门
    数组单步运算
    十天冲刺
  • 原文地址:https://www.cnblogs.com/DriverLao/p/9836626.html
Copyright © 2011-2022 走看看