답안 #964274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964274 2024-04-16T14:12:23 Z Unforgettablepl Examination (JOI19_examination) C++17
20 / 100
64 ms 11316 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int tree[100002];

int get(int x){
    int ans = 0;
    while(x){
        ans+=tree[x];
        x-=x&-x;
    }
    return ans;
}

void add(int x){
    while(x<=100001){
        tree[x]++;
        x+=x&-x;
    }
}

int ans[100001];

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,q;
    cin >> n >> q;
    vector<pair<int,int>> students;
    for(int i=1;i<=n;i++){
        int x,y;cin>>x>>y;
        x = 100001-x;
        y = 100001-y;
        students.emplace_back(x,y);
    }
    vector<tuple<int,int,int>> queries;
    for(int i=1;i<=q;i++){
        int a,b,c;cin>>a>>b>>c;
        a = 100001-a;
        b = 100001-b;
        queries.emplace_back(a,b,i);
    }
    sort(queries.begin(),queries.end());
    sort(students.begin(),students.end());
    auto iter = students.begin();
    for(auto[a,b,idx]:queries){
        while(iter!=students.end() and iter->first<=a){
            add(iter->second);
            iter++;
        }
        ans[idx] = get(b);
    }
    for(int i=1;i<=q;i++)cout<<ans[i]<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 10320 KB Output is correct
2 Correct 64 ms 10460 KB Output is correct
3 Correct 63 ms 10432 KB Output is correct
4 Correct 48 ms 9252 KB Output is correct
5 Correct 52 ms 9660 KB Output is correct
6 Correct 53 ms 8284 KB Output is correct
7 Correct 53 ms 10432 KB Output is correct
8 Correct 53 ms 10320 KB Output is correct
9 Correct 55 ms 10784 KB Output is correct
10 Correct 59 ms 9404 KB Output is correct
11 Correct 48 ms 8896 KB Output is correct
12 Correct 37 ms 7680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 10320 KB Output is correct
2 Correct 64 ms 10460 KB Output is correct
3 Correct 63 ms 10432 KB Output is correct
4 Correct 48 ms 9252 KB Output is correct
5 Correct 52 ms 9660 KB Output is correct
6 Correct 53 ms 8284 KB Output is correct
7 Correct 53 ms 10432 KB Output is correct
8 Correct 53 ms 10320 KB Output is correct
9 Correct 55 ms 10784 KB Output is correct
10 Correct 59 ms 9404 KB Output is correct
11 Correct 48 ms 8896 KB Output is correct
12 Correct 37 ms 7680 KB Output is correct
13 Incorrect 57 ms 11316 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -