Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<algorithm>
- using namespace std;
- #define type int
- int main()
- {
- type cas;
- scanf("%d",&cas);
- type j;
- for(j = 1;j <= cas; j++)
- {
- type array[1000000];
- type n,q,l,h;
- scanf("%d %d",&n,&q);
- type i;
- for(i = 0;i<n;i++)
- {
- scanf("%d",&array[i]);
- }
- printf("%s %d:\n","Case",j );
- while(q)
- {
- scanf("%d %d",&l,&h);
- type *p1 = lower_bound(array,array+n,l);
- type *p2 = lower_bound(array,array+n,h);
- int t = p2 - p1;
- if(*p2 == h)
- t++;
- printf("%d\n",t );
- q--;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement