이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
namespace __gnu_pbds{
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;
struct QUERY {
    int x, y, z, num;
} b[100005];
struct GRADE {
    int x, y;
} a[100005];
int res[100005];
bool cmp(QUERY aa, QUERY bb) {
    return aa.x > bb.x;
}
bool cmp2(GRADE aa, GRADE bb) {
    return aa.x > bb.x;
}
ordered_set t[800005];
map<int, int> mm;
void update(int v, int tl, int tr, int x, int y) {
    if (tl == tr) {
        t[v].insert(y);
        return;
    }
    int mid = (tl + tr) / 2;
    if (mid >= x) update(v * 2, tl, mid, x, y);
    else update(v * 2 + 1, mid + 1, tr, x, y);
    t[v].insert(y);
}
int sum(int v, int tl, int tr, int l, int r, int x) {
    if (l > r) return 0;
    if (tl == l && tr == r) {
        return t[v].size() - t[v].order_of_key(x);
    }
    int mid = (tl + tr) / 2;
    return sum(v * 2, tl, mid, l, min(r, mid), x) + sum(v * 2 + 1, mid + 1, tr, max(l, mid + 1), r, x);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q, z = 0;
    cin >> n >> q;
    vector<int> v;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].x >> a[i].y;
        v.push_back(a[i].y);
    }
    sort(a + 1, a + n + 1, cmp2);
    for (int i = 0; i < q; i++) {
        cin >> b[i].x >> b[i].y >> b[i].z;
        v.push_back(b[i].y);
        b[i].num = i;
    }
    sort(v.begin(), v.end());
    for (int w : v) {
        if (!mm.count(w)) {
            mm[w] = ++z;
        }
    }
    sort(b, b + q, cmp);
    int j = 1;
    for (int i = 0; i < q; i++) {
        while (a[j].x >= b[i].x && j <= n) {
            update(1, 1, z, mm[a[j].y], a[j].x + a[j].y);
            j++;
        }
        res[b[i].num] = sum(1, 1, z, mm[b[i].y], z, b[i].z);
    }
    for (int i = 0; i < q; i++) cout << res[i] << '\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... |