This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ar = array<int, 2>;
const int N = 1e5 + 5;
const long long INF = 1ll << 60;
ar A[N];
int t[3][N], n, q;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> q;
FOR(i, 0, n)
cin >> A[i][0] >> A[i][1];
auto cmp = [&](const auto a, const auto b) {
return a[0] + a[1] < b[0] + b[1];
};
sort(A, A + n, cmp);
FOR(i, 0, n) {
t[0][i] = A[i][0];
t[1][i] = A[i][1];
t[2][i] = A[i][0] + A[i][1];
}
while (q--) {
int a, b, c;
cin >> a >> b >> c;
c = max(c, a + b);
int it = lower_bound(t[2], t[2] + n, c) - t[2];
int ans = 0;
for (; it < n; ++it)
ans += t[0][it] >= a && t[1][it] >= b;
cout << ans << '\n';
}
return 0;
}
# | 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... |