Submission #475141

# Submission time Handle Problem Language Result Execution time Memory
475141 2021-09-21T09:48:07 Z ismoilov Simple game (IZhO17_game) C++14
0 / 100
1 ms 460 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int maxx = 2e5;

int tr[4*maxx];
int n;

void add(int x, int v){
	while(x <= n){
		tr[x] += v;
		x += (x & -x);
	}
}

int sum(int x){
	int s = 0;
	while(x > 0){
		s += tr[x];
		x -= (x & -x);
	}
	return s;
}

void S()
{
	int m;
	cin >> n >> m;
	vector <int> a(n+1);
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
		add(a[i], 1);
	}
	for(int i = 0; i < m; i ++){
		int x;
		cin >> x;
		if(x == 1){
			int c, b;
			cin >> c >> b;
			add(a[c], -1);
			add(b, 1);
		}
		else{
			int b;
			cin >> b;
			cout << sum(b) << "\n";
		}
	}
}

int main()
{
	IOS;
	/*int t;
	cin >> t;
	while(t --)*/
		S();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -