Guest User

Untitled

a guest
Feb 15th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. # include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. set < ll > s;
  8. ll q;
  9.  
  10. main(){
  11.     freopen("exam.in", "r", stdin);
  12.     freopen("exam.out", "w", stdout);
  13.     for(ll i = 1; i <= (ll)3e5; ++i) s.insert(i);
  14.     scanf("%lld", &q);
  15.     while(q--){
  16.         ll x;
  17.         scanf("%lld", &x);
  18.         if(x > 0){
  19.             printf("%lld\n", *s.lower_bound(x));
  20.             s.erase(s.lower_bound(x));
  21.         }
  22.         else{
  23.             s.insert(-x);
  24.         }
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment