Advertisement
ke_timofeeva7

четвертый этаж

Jun 5th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <memory.h>
  7. #include <stdio.h>
  8. #include <stack>
  9. #include <deque>
  10. #include <queue>
  11. #include <vector>
  12. #include <set>
  13. #include <iterator>
  14. #include <map>
  15. #include <iomanip>
  16. #include <unordered_set>
  17. #define int long long
  18. #define pb push_back
  19. #define double long double
  20. #define endl "\n"
  21. #define un unsigned
  22. #define INF 1000000009
  23. #define pii pair<int, int>
  24. #define all(v) v.begin(), v.end()
  25. using namespace std;
  26.  
  27. int n1;
  28.  
  29. istream& operator >> (istream& in, vector<pair<double, string>>& a)
  30. {
  31.     for (int i = 0; i < n1; i++)
  32.     {
  33.         in >> a[i].first >> a[i].second;
  34.     }
  35.  
  36.     return in;
  37. }
  38.  
  39. ostream& operator << (ostream& out, vector<pair<double, string>>& a)
  40. {
  41.     for (int i = n1 - 1; i > -1; i--)
  42.     {
  43.         out << a[i].first << " " << a[i].second << endl;
  44.     }
  45.  
  46.     return out;
  47. }
  48.  
  49.  
  50. signed main()
  51. {
  52.     ios_base::sync_with_stdio();
  53.     cin.tie(0);
  54.     cout.tie(0);
  55.  
  56.     int n;
  57.     cin >> n;
  58.  
  59.     set<int> st;
  60.  
  61.     for (int i = 1; i <= 300000; i++)
  62.     {
  63.         st.insert(i);
  64.     }
  65.  
  66.     for (int i = 0; i < n; i++)
  67.     {
  68.         int a;
  69.         cin >> a;
  70.  
  71.         if (a < 0)
  72.         {
  73.             st.insert(-a);
  74.         }
  75.         else
  76.         {
  77.             auto it = st.find(a);
  78.  
  79.             if (it == st.end())
  80.             {
  81.                 it = st.upper_bound(a);
  82.             }
  83.  
  84.             cout << *it << endl;
  85.  
  86.             st.erase(it);
  87.         }
  88.     }
  89.  
  90.     return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement