Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <iomanip>
- #include <cstring>
- #include <string>
- #include <algorithm>
- #include <queue>
- #include <map>
- #include <set>
- #include <vector>
- #include <iomanip>
- #include <ctime>
- #include <string>
- #include <cstring>
- #include <cmath>
- #define pb push_back
- #define mp make_pair
- #define F first
- #define S second
- using namespace std;
- const long long INF = 1000000000000000001ll;
- const int INFint = (1<<28);
- const int MOD = 1000000007;
- //const long double EPS = 1e-8;
- long long s[1000100];
- int a[1000100];
- int main(){
- ios_base::sync_with_stdio(0);
- // freopen("longqueu.in", "r", stdin); freopen("longqueue.out", "w", stdout);
- int x, n;
- cin >> n >> x;
- for(int i = 0; i < n; i++){
- cin >> a[i];
- }
- if (a[0]>=x) {
- s[0] = 1;
- } else {
- s[0] = 0;
- }
- for(int i = 1; i < n; i++){
- if (a[i] >= x){
- s[i] = s[i-1] + 1;
- } else {
- s[i] = s[i-1];
- }
- }
- int m;
- cin >> m;
- int cb = 0;
- int ce = n-1;
- int t;
- int y;
- for(int i = 0; i < m; i++){
- cin >> t;
- if (t == 1){
- cin >> y;
- ce++;
- if (y >= x){
- s[ce] = s[ce-1] + 1;
- } else {
- s[ce] = s[ce-1];
- }
- }
- if (t == 2){
- cb++;
- }
- if (t == 3){
- cin >> y;
- y+= cb;
- if (y == 0){
- cout << 0 << endl;
- } else {
- if (cb == 0){
- cout << s[y - 1] << endl;
- } else {
- // cout << cb -1 << ' ';
- cout << s[y - 1] -s[cb-1] << endl;
- }
- }
- }
- }
- //cerr << clock()/CLOCKS_PER_SEC << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement