This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef int ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(lli = x; i>y; i--)
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
vector<ll> students[100005];
int main(){
ll n,q;
cin >> n >> q;
vector<vector<ll>> st;
FOR(i,0,n){
ll a,b;
cin >> a >> b;
students[a].push_back(b);
}
vector<vector<ll>> queries;
FOR(i,0,q){
ll x,y,z;
cin >> x >> y >> z;
queries.push_back({x,y,z, i});
}
vector<ll> ans(q);
sort(queries.begin(), queries.end());
reverse(queries.begin(), queries.end());
ordered_set stuff;
ll cur = 100004;
for (auto&i : queries){
while (cur >= i[0]){
for (auto&i : students[cur]) stuff.insert(i);
cur--;
}
// cout << i[1] << endl;
// for (auto&i : stuff) cout << i << " ";
// cout << endl;
// cout << stuff.order_of_key(i[1]) << endl;
ans[i[3]] = stuff.size() - stuff.order_of_key(i[1]);
}
for (auto&i : ans) cout << i << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |