Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstdlib>
  4. #include <iomanip>
  5. #include <cstring>
  6. #include <string>
  7. #include <algorithm>
  8. #include <queue>
  9. #include <map>
  10. #include <set>
  11. #include <vector>
  12. #include <iomanip>
  13. #include <ctime>
  14. #include <string>
  15. #include <cstring>
  16. #include <cmath>
  17.  
  18. #define pb push_back
  19. #define mp make_pair
  20. #define F first
  21. #define S second
  22.  
  23. using namespace std;
  24.  
  25. const long long INF = 1000000000000000001ll;
  26. const int INFint = (1<<28);
  27. const int MOD = 1000000007;
  28. //const long double EPS = 1e-8;
  29.  
  30. long long s[1000100];
  31. int a[1000100];
  32.  
  33. int main(){
  34.     ios_base::sync_with_stdio(0);
  35. //    freopen("longqueu.in", "r", stdin); freopen("longqueue.out", "w", stdout);
  36.     int x, n;
  37.     cin >> n >> x;
  38.  
  39.        for(int i = 0; i < n; i++){
  40.         cin >> a[i];
  41.     }
  42.     if (a[0]>=x) {
  43.         s[0] = 1;
  44.     } else {
  45.         s[0] = 0;
  46.     }
  47.     for(int i = 1; i < n; i++){
  48.         if (a[i] >= x){
  49.             s[i] = s[i-1] + 1;
  50.         } else {
  51.             s[i] = s[i-1];
  52.         }
  53.     }
  54.  
  55.     int m;
  56.     cin >> m;
  57.  
  58.     int cb = 0;
  59.     int ce = n-1;
  60.     int t;
  61.     int y;
  62.  
  63.     for(int i = 0; i < m; i++){
  64.         cin >> t;
  65.         if (t == 1){
  66.             cin >> y;
  67.             ce++;
  68.             if (y >= x){
  69.                 s[ce] = s[ce-1] + 1;
  70.             } else {
  71.                 s[ce] = s[ce-1];
  72.             }
  73.         }
  74.         if (t == 2){
  75.             cb++;
  76.         }
  77.         if (t == 3){
  78.             cin >> y;
  79.             y+= cb;
  80.             if (y == 0){
  81.                 cout << 0 << endl;
  82.             } else {
  83.                 if (cb == 0){
  84.                     cout << s[y - 1] << endl;
  85.                 } else {
  86.                   //  cout << cb -1 << ' ';
  87.                     cout << s[y - 1] -s[cb-1] << endl;
  88.                 }
  89.             }
  90.         }
  91.     }
  92.  
  93.     //cerr << clock()/CLOCKS_PER_SEC << endl;
  94.     return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement