답안 #715881

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715881 2023-03-28T10:00:14 Z ismayil Examination (JOI19_examination) C++17
43 / 100
641 ms 76716 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAX = 1e5;
struct fenwick_tree{
    int bit[MAX + 1] = {0};
    void update(int pos, int val){
        for(int i = pos; i <= MAX; i = i | (i + 1)){
            bit[i] += val;
        }
    }
    int query(int pos){
        int res = 0;
        for(int i = pos; i >= 0; i = (i & (i + 1)) - 1){
            res += bit[i];
        }
        return res;
    }
    int query(int l, int r){
        if(l == 0) return query(r);
        return query(r) - query(l - 1);
    }
};
struct event{
    int x, y, z, idx, type;
    bool operator<(event other){
        if(z == other.z) return type < other.type;
        return z > other.z;
    }
};
int n, m;
void solve(){
    vector<event> events;
    map<int, int> mm;
    for(int i = 0; i < n; i++){
        int x, y;
        cin>>x>>y;
        mm[x]; mm[y];
        events.push_back({x, y, x + y, -1, 0});
    }
    for(int i = 0; i < m; i++){
        int x, y, z;
        cin>>x>>y>>z;
        mm[x]; mm[y];
        events.push_back({x, y, max(x + y, z), i, 1});
    }
    int idx = 0;
    for(auto& i : mm) i.second = idx++;
    sort(events.begin(), events.end());
    int ans[m];
    fenwick_tree X, Y;
    int cnt = 0;
    for (auto i : events)
    {
        if(i.type == 0){
            Y.update(mm[i.y], 1);
            X.update(mm[i.x], 1);
            cnt++;
        }else{
            ans[i.idx] = Y.query(mm[i.y], MAX) + X.query(mm[i.x], MAX) - cnt;
        }
    }
    for (int i = 0; i < m; i++) cout<<ans[i]<<endl;
}
signed main(){
    
    cin>>n>>m;
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1748 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 2 ms 1752 KB Output is correct
7 Correct 19 ms 2972 KB Output is correct
8 Correct 16 ms 2996 KB Output is correct
9 Correct 17 ms 2972 KB Output is correct
10 Correct 13 ms 2616 KB Output is correct
11 Correct 14 ms 2620 KB Output is correct
12 Correct 8 ms 2368 KB Output is correct
13 Correct 16 ms 2988 KB Output is correct
14 Correct 16 ms 3004 KB Output is correct
15 Correct 15 ms 3020 KB Output is correct
16 Correct 10 ms 2584 KB Output is correct
17 Correct 13 ms 2612 KB Output is correct
18 Correct 8 ms 2356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 547 ms 17860 KB Output is correct
2 Correct 584 ms 17868 KB Output is correct
3 Correct 587 ms 17932 KB Output is correct
4 Correct 356 ms 16592 KB Output is correct
5 Correct 344 ms 16620 KB Output is correct
6 Correct 226 ms 12252 KB Output is correct
7 Correct 492 ms 17736 KB Output is correct
8 Correct 557 ms 17872 KB Output is correct
9 Correct 479 ms 17616 KB Output is correct
10 Correct 357 ms 16668 KB Output is correct
11 Correct 392 ms 16676 KB Output is correct
12 Correct 210 ms 12136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 547 ms 17860 KB Output is correct
2 Correct 584 ms 17868 KB Output is correct
3 Correct 587 ms 17932 KB Output is correct
4 Correct 356 ms 16592 KB Output is correct
5 Correct 344 ms 16620 KB Output is correct
6 Correct 226 ms 12252 KB Output is correct
7 Correct 492 ms 17736 KB Output is correct
8 Correct 557 ms 17872 KB Output is correct
9 Correct 479 ms 17616 KB Output is correct
10 Correct 357 ms 16668 KB Output is correct
11 Correct 392 ms 16676 KB Output is correct
12 Correct 210 ms 12136 KB Output is correct
13 Correct 641 ms 17880 KB Output is correct
14 Correct 549 ms 17816 KB Output is correct
15 Correct 617 ms 17956 KB Output is correct
16 Correct 414 ms 16604 KB Output is correct
17 Correct 415 ms 16708 KB Output is correct
18 Correct 217 ms 12140 KB Output is correct
19 Correct 558 ms 17832 KB Output is correct
20 Correct 589 ms 17900 KB Output is correct
21 Correct 530 ms 17768 KB Output is correct
22 Correct 375 ms 16612 KB Output is correct
23 Correct 351 ms 16664 KB Output is correct
24 Correct 206 ms 12208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1748 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 2 ms 1752 KB Output is correct
7 Correct 19 ms 2972 KB Output is correct
8 Correct 16 ms 2996 KB Output is correct
9 Correct 17 ms 2972 KB Output is correct
10 Correct 13 ms 2616 KB Output is correct
11 Correct 14 ms 2620 KB Output is correct
12 Correct 8 ms 2368 KB Output is correct
13 Correct 16 ms 2988 KB Output is correct
14 Correct 16 ms 3004 KB Output is correct
15 Correct 15 ms 3020 KB Output is correct
16 Correct 10 ms 2584 KB Output is correct
17 Correct 13 ms 2612 KB Output is correct
18 Correct 8 ms 2356 KB Output is correct
19 Correct 547 ms 17860 KB Output is correct
20 Correct 584 ms 17868 KB Output is correct
21 Correct 587 ms 17932 KB Output is correct
22 Correct 356 ms 16592 KB Output is correct
23 Correct 344 ms 16620 KB Output is correct
24 Correct 226 ms 12252 KB Output is correct
25 Correct 492 ms 17736 KB Output is correct
26 Correct 557 ms 17872 KB Output is correct
27 Correct 479 ms 17616 KB Output is correct
28 Correct 357 ms 16668 KB Output is correct
29 Correct 392 ms 16676 KB Output is correct
30 Correct 210 ms 12136 KB Output is correct
31 Correct 641 ms 17880 KB Output is correct
32 Correct 549 ms 17816 KB Output is correct
33 Correct 617 ms 17956 KB Output is correct
34 Correct 414 ms 16604 KB Output is correct
35 Correct 415 ms 16708 KB Output is correct
36 Correct 217 ms 12140 KB Output is correct
37 Correct 558 ms 17832 KB Output is correct
38 Correct 589 ms 17900 KB Output is correct
39 Correct 530 ms 17768 KB Output is correct
40 Correct 375 ms 16612 KB Output is correct
41 Correct 351 ms 16664 KB Output is correct
42 Correct 206 ms 12208 KB Output is correct
43 Runtime error 563 ms 76716 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -