This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, q;
cin >> n >> q;
vector<pair<ll, ll>> v(n);
vector<ll> val(n);
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
}
sort(all(v));
for (int i = 0; i < n; i++) val[i] = v[i].first;
while (q--) {
ll x, y, z;
cin >> x >> y >> z;
if (x > val[n - 1]) {
cout << 0 << endl;
continue;
}
int lower = lower_bound(all(val), x) - val.begin(), ans = 0;
for (int i = lower; i < n; i++) ans += (v[i].second >= y && v[i].first + v[i].second >= z);
cout << ans << endl;
}
}
# | 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... |