fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5.  
  6. int main(){
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. int n,q;
  10. cin>>n>>q;
  11. vector<pair<int,int>>p;
  12. for(int i=0;i<n;i++){
  13. int u;
  14. cin>>u;
  15. p.push_back({u,0}); // point is starting
  16. cin>>u;
  17. p.push_back({u,1}); // point is ending
  18. }
  19. sort(p.begin(),p.end());
  20. unordered_map<int,int>mp;
  21. int c=0;
  22. for(auto &i:p){
  23. if(i.second==0){
  24. c++;
  25. mp[i.first]=c;
  26. }
  27. else{
  28. if(mp.find(i.first)==mp.end())mp[i.first]=c;
  29. c--;
  30. }
  31. }
  32. for(int i=0;i<q;i++){
  33. cin>>c;
  34. cout<<mp[c]<<" ";
  35. }
  36. cout<<"\n";
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout