Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // B regional second tour ??/?? B 100(Accepted)
- # include <stack>
- # include <vector>
- # include <iostream>
- # include <algorithm>
- using namespace std;
- int main() {
- size_t n;
- cin >> n;
- stack<pair<int32_t, int32_t>> st;
- vector<int32_t> c_time;
- for (size_t i = 0; i < n; i++) {
- int32_t x, e;
- cin >> x >> e;
- if (e == 1) {
- st.push(make_pair(x, e));
- } else if (!st.empty() && e == -1) {
- int32_t x_pop;
- x_pop = st.top().first;
- c_time.push_back((x - x_pop + 1) / 2);
- st.pop();
- }
- }
- size_t t;
- cin >> t;
- sort(c_time.rbegin(), c_time.rend());
- for (size_t i = 0; i < t; i++) {
- int32_t cur_t;
- cin >> cur_t;
- while (!c_time.empty() && c_time.back() <= cur_t) {
- c_time.pop_back();
- n -= 2;
- }
- cout << n << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement