Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 2e5 + 5;
  5. const int INF = 0x3f3f3f3f;
  6.  
  7. int n, m, l, r, ok[N], cnt[N], idx = 1;
  8. vector<int> v;
  9. queue<int> t;
  10.  
  11. int main(){
  12.     ios_base::sync_with_stdio(0), cin.tie(0);
  13.     cin >> n >> m;
  14.     v.resize(n+m);
  15.     for(int i = 0; i < n+m; i++) cin >> v[i];
  16.     for(int i = 0; i < n+m; i++) {
  17.         cin >> ok[i];
  18.         if (ok[i]) t.push(v[i]);
  19.     }
  20.     l = t.front(); t.pop();
  21.     if(t.size()) r = t.front(), t.pop();
  22.     else r = INF;
  23.     for(int i = 0; i < n+m; i++){
  24.         if(v[i] >= r and t.size()) l = r, r = t.front(), t.pop(), idx++;
  25.         if(!ok[i]) (abs(r - v[i]) < abs(l - v[i]) and r != INF) ? cnt[idx+1]++ : cnt[idx]++;
  26.     }
  27.     for(int i = 1; i <= m; i++) cout << cnt[i] << " ";
  28.     cout << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement