#include <bits/stdc++.h>
// struct SegmentTree {
// public:
// std::vector<int> seg;
// int n;
// SegmentTree(int n) : n(n) { seg.resize(2 * n); }
// void add(int idx, int del) {
// for (seg[idx += n] += del; idx > 1; idx /= 2) {
// seg[idx / 2] = seg[idx] + seg[idx ^ 1];
// }
// }
// int query(int l, int r) {
// int ans = 0;
// for (l += n, r += n + 1; l < r; l /= 2, r /= 2) {
// if (l & 1) {
// ans += seg[l++];
// }
// if (r & 1) {
// ans += seg[--r];
// }
// }
// return ans;
// }
// };
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, q;
std::cin >> n >> q;
std::vector<std::pair<int, int>> a(n);
for (auto &[s, t] : a) {
std::cin >> s >> t;
}
struct Query {
int x, y, z;
int i;
};
std::vector<Query> queries;
for (int i = 0, x, y, z; i < q; ++i) {
std::cin >> x >> y >> z;
queries.push_back({x, y, z, i});
}
for (auto &[x, y, z, i] : queries) {
int ans = 0;
for (auto &[a, b] : a) {
ans += a >= x and b >= y and a + b >= z;
}
std::cout << ans << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |