Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <set>
  5. #include <map>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main() {
  11. set <int> a;
  12. int n, x, i, k, y;
  13. a.insert(0);
  14. a.insert(1000000);
  15.  
  16. cin >> n >> k;
  17.  
  18. for (int j = 1; j <= k; j++) {
  19. cin >> i;
  20. if (i != 0) {
  21. a.insert(i);
  22.  
  23. }
  24. else {
  25. cin >> x >> y;
  26. auto p1 = a.lower_bound(x);
  27.  
  28. int p = distance(a.begin(), p1);
  29. p1 = a.lower_bound(y);
  30.  
  31. int q = distance(a.begin(), p1);
  32. if (*p1 != y) q--;
  33.  
  34. cout << q - p + 1 << endl;
  35. //cout << q << " " << p << endl;
  36.  
  37.  
  38. }
  39.  
  40. }
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement