deushiro

Untitled

Jan 7th, 2020
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. int main()
  8. {
  9.     int n;
  10.     cin >> n;
  11.     vector<pair<int, int>> a;
  12.     for(int i = 0; i < n; ++i){
  13.         int x, v;
  14.         cin >> x >> v;
  15.         a.push_back({x * 2, v});
  16.     }
  17.     int m;
  18.     cin >> m;
  19.     vector<int> t(m);
  20.     vector<int> st;
  21.     map<int, ll> ts;
  22.     for(int i = 0; i < m; ++i){
  23.         cin >> t[i];
  24.         t[i] *= 2;
  25.     }
  26.     int c = n;
  27.     for(int i = 0; i < n; ++i){
  28.         if(a[i].second == 1){
  29.             st.push_back(a[i].first);
  30.         }
  31.         else{
  32.             if(st.size() == 0)
  33.                 continue;
  34.             else{
  35.                 int z = st.pop_back();
  36.                 ts[abs(z + a[i].first) / 2] += 2 * 1LL;
  37.             }
  38.         }
  39.     }
  40.     int i = 0;
  41.     for(pair<int, ll> k : ts){
  42.         for(int j = i; j < m; ++j){
  43.             if(t[j] < k.first){
  44.                 cout << c << "\n";
  45.             }
  46.             else{
  47.                 c -= k.second;
  48.                 i = j;
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment