Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<algorithm>
  3. using namespace std;
  4. #define type int
  5. int main()
  6. {
  7. type cas;
  8. scanf("%d",&cas);
  9. type j;
  10. for(j = 1;j <= cas; j++)
  11. {
  12. type array[1000000];
  13. type n,q,l,h;
  14. scanf("%d %d",&n,&q);
  15. type i;
  16. for(i = 0;i<n;i++)
  17. {
  18. scanf("%d",&array[i]);
  19. }
  20. printf("%s %d:\n","Case",j );
  21. while(q)
  22. {
  23. scanf("%d %d",&l,&h);
  24. type *p1 = lower_bound(array,array+n,l);
  25. type *p2 = lower_bound(array,array+n,h);
  26. int t = p2 - p1;
  27. if(*p2 == h)
  28. t++;
  29. printf("%d\n",t );
  30. q--;
  31. }
  32. }
  33. return 0;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement