Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* a450 */
- /* AC (0.8s, 3.9MB) */
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- const int MAXN = 1000001;
- int N, Q, l, r, a, b;
- int hight[MAXN];
- int main()
- {
- scanf("%d %d", &N, &Q);
- for(int i = 0; i < N; ++i) scanf("%d", hight + i);
- sort(hight, hight + N);
- while(Q--)
- {
- scanf("%d %d", &a, &b);
- l = lower_bound(hight, hight + N, a) - hight;
- r = upper_bound(hight, hight + N, b) - hight;
- if(r - l > 0) printf("%d\n", r - l);
- else puts("The candies are too short");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement