SHARE
TWEET

a450

Emiliatan Jun 16th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* a450             */
  2. /* AC (0.8s, 3.9MB) */
  3. #include <cstdio>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. const int MAXN = 1000001;
  9.  
  10. int N, Q, l, r, a, b;
  11. int hight[MAXN];
  12.  
  13. int main()
  14. {
  15.     scanf("%d %d", &N, &Q);
  16.     for(int i = 0; i < N; ++i) scanf("%d", hight + i);
  17.     sort(hight, hight + N);
  18.     while(Q--)
  19.     {
  20.         scanf("%d %d", &a, &b);
  21.         l = lower_bound(hight, hight + N, a) - hight;
  22.         r = upper_bound(hight, hight + N, b) - hight;
  23.         if(r - l > 0) printf("%d\n", r - l);
  24.         else puts("The candies are too short");
  25.     }
  26.     return 0;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top