Advertisement
kdzhr

Untitled

Jan 6th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. // B regional second tour ??/?? B 100(Accepted)
  2.  
  3. # include <stack>
  4. # include <vector>
  5. # include <iostream>
  6. # include <algorithm>
  7. using namespace std;
  8.  
  9. int main() {
  10.     size_t n;
  11.     cin >> n;
  12.     stack<pair<int32_t, int32_t>> st;
  13.     vector<int32_t> c_time;
  14.     for (size_t i = 0; i < n; i++) {
  15.         int32_t x, e;
  16.         cin >> x >> e;
  17.         if (e == 1) {
  18.             st.push(make_pair(x, e));
  19.         } else if (!st.empty() && e == -1) {
  20.             int32_t x_pop;
  21.             x_pop = st.top().first;
  22.             c_time.push_back((x - x_pop + 1) / 2);
  23.             st.pop();
  24.         }
  25.     }
  26.     size_t t;
  27.     cin >> t;
  28.     sort(c_time.rbegin(), c_time.rend());
  29.     for (size_t i = 0; i < t; i++) {
  30.         int32_t cur_t;
  31.         cin >> cur_t;
  32.         while (!c_time.empty() && c_time.back() <= cur_t) {
  33.             c_time.pop_back();
  34.             n -= 2;
  35.         }
  36.         cout << n << '\n';
  37.     }
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement