Advertisement
Misbah_Uddin_Tareq

Interval by mazhar vai

May 31st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4. #define pb push_back
  5. #define pii pair<int,int>
  6. #define ff first
  7. #define ss second
  8. #define mx 100005
  9. #define endl "\n"
  10. const ll mod=1e9+7;
  11.  
  12. vector<int>mp[550];
  13. int main()
  14. {
  15.     ios::sync_with_stdio(0);
  16.     cin.tie(0);
  17.  
  18.     ll n,m,q;
  19.     cin>>n>>m>>q;
  20.     while(m--)
  21.     {
  22.         ll l,r;
  23.         cin>>l>>r;
  24.         for(int i=1; i<=l; i++)
  25.             mp[i].pb(r);
  26.     }
  27.  
  28.     for(int i=1; i<=500; i++)
  29.     {
  30.         if(mp[i].size())
  31.             sort(mp[i].begin(),mp[i].end());
  32.     }
  33.  
  34.     while(q--)
  35.     {
  36.         ll l,r;
  37.         cin>>l>>r;
  38.  
  39.         /// r ta l er kotho no. position o ase
  40.         ll pos=upper_bound(mp[l].begin(),mp[l].end(),r)-mp[l].begin();
  41.         cout<<pos<<endl;
  42.     }
  43.  
  44.  
  45.     return 0;
  46. }
  47.  
  48. // https://www.hackerrank.com/contests/competencia-de-gente-perezosa-round-0-match-0-group-a/challenges/blacknerd-and-his-queries
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement