#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX = 1e5;
int bit[MAX + 1];
void update(int pos, int val){
for(int i = pos; i <= MAX; i += i & -i){
bit[i] += val;
}
}
int ask(int pos){
int res = 0;
for(int i = pos; i > 0; i -= i & -i){
res += bit[i];
}
return res;
}
int ask(int l, int r){
if(l == 0) return ask(r);
return ask(r) - ask(l - 1);
}
struct query{
int x, y, idx;
bool operator<(query other){
return x > other.x;
}
};
int main(){
int n, m;
cin>>n>>m;
vector<pair<int, int>> p;
for(int i = 0; i < n; i++){
int x, y;
cin>>x>>y;
p.push_back({x, y});
}
sort(p.begin(), p.end());
reverse(p.begin(), p.end());
vector<query> queries;
for(int i = 0; i < m; i++){
int x, y, z;
cin>>x>>y>>z;
queries.push_back({x, y, i});
}
sort(queries.begin(), queries.end());
int ans[m];
int idx = 0;
for (int i = 0; i < m; i++)
{
while(idx < n && queries[i].x <= p[idx].first){
update(p[idx].second, 1);
idx++;
}
ans[queries[i].idx] = ask(queries[i].y, MAX);
}
for (int i = 0; i < m; i++) cout<<ans[i]<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3044 ms |
3820 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3044 ms |
3820 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |