Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int testCnt;
- void solve(int tc) {
- cout << "Case " << tc << ":" << endl;
- int n, q;
- cin >> n >> q;
- vector<pair<pair<int, int>, int>> b;
- for (int i = 0; i < n; ++i) {
- int l, r;
- cin >> l >> r;
- b.push_back({{l, 0}, i});
- b.push_back({{r, 2}, i});
- }
- for (int i = 0; i < q; ++i) {
- int x;
- cin >> x;
- b.push_back({{x, 1}, i});
- }
- sort(b.begin(), b.end());
- vector<int> ans(q);
- int cur = 0;
- for (auto x : b) {
- int p = x.first.first;
- int type = x.first.second;
- int id = x.second;
- if (type == 0) {
- cur++;
- } else if (type == 1) {
- ans[id] = cur;
- } else {
- cur--;
- }
- }
- for (int i = 0; i < q; ++i) {
- cout << ans[i] << endl;
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0); cout.tie(0);
- cin >> testCnt;
- for (int tc = 1; tc <= testCnt; ++tc) {
- solve(tc);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement