Advertisement
hkshakib

Untitled

Mar 24th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,cnt=1;
  6. scanf("%d",&t);
  7. while(t--)
  8. {
  9. int n,q;
  10. scanf("%d%d",&n,&q);
  11. vector<int> seg1(n),seg2(n);
  12. for(int i=0; i<n; i++)
  13. {
  14. scanf("%d%d",&seg1[i],&seg2[i]);
  15. }
  16. sort(seg1.begin(),seg1.end());
  17. sort(seg2.begin(),seg2.end());
  18. printf("Case %d:\n",cnt++);
  19. while(q--)
  20. {
  21. int x ;
  22. scanf("%d",&x);
  23. int low = upper_bound(seg1.begin(),seg1.end(),x)-seg1.begin();
  24. int start = lower_bound(seg2.begin(),seg2.end(),x)-seg2.begin();
  25. printf("%d\n",low-start);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement