답안 #839428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839428 2023-08-30T03:00:24 Z adaawf Examination (JOI19_examination) C++14
100 / 100
2364 ms 164580 KB
#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++;
            //cout << j << " " << a[j].x << " " << b[i].x << endl;
        }
        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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 62932 KB Output is correct
2 Correct 45 ms 62844 KB Output is correct
3 Correct 43 ms 62904 KB Output is correct
4 Correct 44 ms 62940 KB Output is correct
5 Correct 44 ms 62868 KB Output is correct
6 Correct 44 ms 62944 KB Output is correct
7 Correct 57 ms 65268 KB Output is correct
8 Correct 59 ms 65276 KB Output is correct
9 Correct 56 ms 65268 KB Output is correct
10 Correct 48 ms 63700 KB Output is correct
11 Correct 57 ms 65228 KB Output is correct
12 Correct 49 ms 63688 KB Output is correct
13 Correct 57 ms 65196 KB Output is correct
14 Correct 55 ms 65316 KB Output is correct
15 Correct 58 ms 65268 KB Output is correct
16 Correct 56 ms 65232 KB Output is correct
17 Correct 46 ms 63456 KB Output is correct
18 Correct 46 ms 63400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1626 ms 153344 KB Output is correct
2 Correct 1646 ms 153256 KB Output is correct
3 Correct 1717 ms 153280 KB Output is correct
4 Correct 265 ms 88412 KB Output is correct
5 Correct 1169 ms 153224 KB Output is correct
6 Correct 271 ms 88528 KB Output is correct
7 Correct 1646 ms 153388 KB Output is correct
8 Correct 1650 ms 150312 KB Output is correct
9 Correct 1599 ms 150368 KB Output is correct
10 Correct 1088 ms 153136 KB Output is correct
11 Correct 159 ms 76304 KB Output is correct
12 Correct 262 ms 80900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1626 ms 153344 KB Output is correct
2 Correct 1646 ms 153256 KB Output is correct
3 Correct 1717 ms 153280 KB Output is correct
4 Correct 265 ms 88412 KB Output is correct
5 Correct 1169 ms 153224 KB Output is correct
6 Correct 271 ms 88528 KB Output is correct
7 Correct 1646 ms 153388 KB Output is correct
8 Correct 1650 ms 150312 KB Output is correct
9 Correct 1599 ms 150368 KB Output is correct
10 Correct 1088 ms 153136 KB Output is correct
11 Correct 159 ms 76304 KB Output is correct
12 Correct 262 ms 80900 KB Output is correct
13 Correct 2057 ms 153196 KB Output is correct
14 Correct 1547 ms 153220 KB Output is correct
15 Correct 1943 ms 153220 KB Output is correct
16 Correct 316 ms 88400 KB Output is correct
17 Correct 1153 ms 153348 KB Output is correct
18 Correct 349 ms 88432 KB Output is correct
19 Correct 2160 ms 153244 KB Output is correct
20 Correct 2123 ms 153244 KB Output is correct
21 Correct 2256 ms 152212 KB Output is correct
22 Correct 1134 ms 152960 KB Output is correct
23 Correct 147 ms 76232 KB Output is correct
24 Correct 264 ms 80776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 62932 KB Output is correct
2 Correct 45 ms 62844 KB Output is correct
3 Correct 43 ms 62904 KB Output is correct
4 Correct 44 ms 62940 KB Output is correct
5 Correct 44 ms 62868 KB Output is correct
6 Correct 44 ms 62944 KB Output is correct
7 Correct 57 ms 65268 KB Output is correct
8 Correct 59 ms 65276 KB Output is correct
9 Correct 56 ms 65268 KB Output is correct
10 Correct 48 ms 63700 KB Output is correct
11 Correct 57 ms 65228 KB Output is correct
12 Correct 49 ms 63688 KB Output is correct
13 Correct 57 ms 65196 KB Output is correct
14 Correct 55 ms 65316 KB Output is correct
15 Correct 58 ms 65268 KB Output is correct
16 Correct 56 ms 65232 KB Output is correct
17 Correct 46 ms 63456 KB Output is correct
18 Correct 46 ms 63400 KB Output is correct
19 Correct 1626 ms 153344 KB Output is correct
20 Correct 1646 ms 153256 KB Output is correct
21 Correct 1717 ms 153280 KB Output is correct
22 Correct 265 ms 88412 KB Output is correct
23 Correct 1169 ms 153224 KB Output is correct
24 Correct 271 ms 88528 KB Output is correct
25 Correct 1646 ms 153388 KB Output is correct
26 Correct 1650 ms 150312 KB Output is correct
27 Correct 1599 ms 150368 KB Output is correct
28 Correct 1088 ms 153136 KB Output is correct
29 Correct 159 ms 76304 KB Output is correct
30 Correct 262 ms 80900 KB Output is correct
31 Correct 2057 ms 153196 KB Output is correct
32 Correct 1547 ms 153220 KB Output is correct
33 Correct 1943 ms 153220 KB Output is correct
34 Correct 316 ms 88400 KB Output is correct
35 Correct 1153 ms 153348 KB Output is correct
36 Correct 349 ms 88432 KB Output is correct
37 Correct 2160 ms 153244 KB Output is correct
38 Correct 2123 ms 153244 KB Output is correct
39 Correct 2256 ms 152212 KB Output is correct
40 Correct 1134 ms 152960 KB Output is correct
41 Correct 147 ms 76232 KB Output is correct
42 Correct 264 ms 80776 KB Output is correct
43 Correct 2190 ms 164124 KB Output is correct
44 Correct 2312 ms 164128 KB Output is correct
45 Correct 2190 ms 164180 KB Output is correct
46 Correct 318 ms 88268 KB Output is correct
47 Correct 1743 ms 164180 KB Output is correct
48 Correct 297 ms 88152 KB Output is correct
49 Correct 2364 ms 164220 KB Output is correct
50 Correct 2194 ms 164064 KB Output is correct
51 Correct 2203 ms 164196 KB Output is correct
52 Correct 1355 ms 164580 KB Output is correct
53 Correct 217 ms 76896 KB Output is correct