답안 #964438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964438 2024-04-16T21:47:22 Z Unforgettablepl Examination (JOI19_examination) C++17
0 / 100
57 ms 17288 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int tree[100001];

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

void add(int x){
    while(x<=100000){
        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;
        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;
        queries.emplace_back(a,b,i);
    }
    sort(queries.rbegin(),queries.rend());
    sort(students.rbegin(),students.rend());
    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(100000)-get(b-1);
    }
    for(int i=1;i<=q;i++)cout<<ans[i]<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 57 ms 17288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 57 ms 17288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -