Advertisement
Saleh127

Untitled

Apr 27th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int a[200005],t,i,b,c,d,e,j,k,up,lo;
  6. scanf("%d",&t);
  7. for(i=1; i<=t; i++)
  8. {
  9. scanf("%d %d",&b,&c);
  10. for(j=0; j<b; j++)
  11. {
  12. cin>>a[j];
  13. }
  14. printf("Case %d:\n",i);
  15. while(c--)
  16. {
  17. scanf("%d %d",&d,&e);
  18. lo=lower_bound(a,a+b,d)-a;
  19. up=upper_bound(a,a+b,e)-a;
  20. int ans=up-lo;
  21. printf("%d\n",ans);
  22. }
  23. }
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement