Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- int n;
- cin >> n;
- vector<pair<int, int>> a;
- for(int i = 0; i < n; ++i){
- int x, v;
- cin >> x >> v;
- a.push_back({x * 2, v});
- }
- int m;
- cin >> m;
- vector<int> t(m);
- vector<int> st;
- map<int, ll> ts;
- for(int i = 0; i < m; ++i){
- cin >> t[i];
- t[i] *= 2;
- }
- int c = n;
- for(int i = 0; i < n; ++i){
- if(a[i].second == 1){
- st.push_back(a[i].first);
- }
- else{
- if(st.size() == 0)
- continue;
- else{
- int z = st.pop_back();
- ts[abs(z + a[i].first) / 2] += 2 * 1LL;
- }
- }
- }
- int i = 0;
- for(pair<int, ll> k : ts){
- for(int j = i; j < m; ++j){
- if(t[j] < k.first){
- cout << c << "\n";
- }
- else{
- c -= k.second;
- i = j;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment