Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define LL int
- const LL MOD=1e9+7;
- // When something is important enough, you do it even if the odds are not in your favor.
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- #ifdef somujena
- freopen("/home/somujena/competitive/input.txt", "r", stdin);
- freopen("/home/somujena/competitive/output.txt", "w", stdout);
- #endif
- // code goes here
- LL test=1; cin>>test;
- while(test--){
- LL n,q,i,j;cin>>n>>q;
- pair<LL,LL> a[n];
- for(i = 0; i < n; i++) cin>>a[i].first>>a[i].second,a[i].second*=-1;
- sort(a,a+n);
- reverse(a,a+n);
- for(i = 0; i < n; i++) a[i].second*=-1;
- std::vector<LL> v;
- set<pair<LL,LL> > s;
- LL m[n+4];
- for(i = 0; i < n+4; i++) m[i]=0;
- LL r=0;
- for(i = 0; i < n; i++){
- if(i>0&&a[i]==a[i-1]){
- m[*v.rbegin()]++;
- r++;
- }
- else{
- s.insert(a[i]);
- r++;
- v.push_back(r);
- m[*v.rbegin()]++;
- }
- }
- while(q--){
- LL r,i,j;cin>>r;
- LL in=upper_bound(v.begin(), v.end(),r)-v.begin();in--;
- cout<<m[v[in]]<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement