#include <bits/stdc++.h>
using namespace std;
#define int long long
int tree[100002];
int get(int x){
int ans = 0;x++;
while(x){
ans+=tree[x];
x-=x&-x;
}
return ans;
}
void add(int x){
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;
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 |
Correct |
67 ms |
8024 KB |
Output is correct |
2 |
Correct |
64 ms |
10432 KB |
Output is correct |
3 |
Correct |
56 ms |
10464 KB |
Output is correct |
4 |
Correct |
52 ms |
9004 KB |
Output is correct |
5 |
Correct |
54 ms |
9716 KB |
Output is correct |
6 |
Correct |
47 ms |
8212 KB |
Output is correct |
7 |
Correct |
61 ms |
10368 KB |
Output is correct |
8 |
Correct |
58 ms |
10364 KB |
Output is correct |
9 |
Correct |
58 ms |
10688 KB |
Output is correct |
10 |
Correct |
51 ms |
9444 KB |
Output is correct |
11 |
Correct |
58 ms |
8920 KB |
Output is correct |
12 |
Correct |
46 ms |
8696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
67 ms |
8024 KB |
Output is correct |
2 |
Correct |
64 ms |
10432 KB |
Output is correct |
3 |
Correct |
56 ms |
10464 KB |
Output is correct |
4 |
Correct |
52 ms |
9004 KB |
Output is correct |
5 |
Correct |
54 ms |
9716 KB |
Output is correct |
6 |
Correct |
47 ms |
8212 KB |
Output is correct |
7 |
Correct |
61 ms |
10368 KB |
Output is correct |
8 |
Correct |
58 ms |
10364 KB |
Output is correct |
9 |
Correct |
58 ms |
10688 KB |
Output is correct |
10 |
Correct |
51 ms |
9444 KB |
Output is correct |
11 |
Correct |
58 ms |
8920 KB |
Output is correct |
12 |
Correct |
46 ms |
8696 KB |
Output is correct |
13 |
Incorrect |
69 ms |
10888 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |