Submission #341365

# Submission time Handle Problem Language Result Execution time Memory
341365 2020-12-29T14:50:13 Z nandonathaniel Simple game (IZhO17_game) C++14
0 / 100
3 ms 4204 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005,MAXV=1000005;

int bit[MAXV],a[MAXN];

void update(int now,int val){
	for(int i=now;i<=MAXV;i+=(i&(-i)))bit[i]+=val;
}

int query(int now){
	int ret=0;
	for(int i=now;i>0;i-=(i&(-i)))ret+=bit[i];
	return ret;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,q,op,x,y;
	cin >> n >> q;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		update(a[i],1);
	}
	while(q--){
		cin >> op >> x;
		if(op==1){
			cin >> y;
			update(a[x],-1);
			a[x]=y;
			update(a[x],1);
		}
		else{
			cout << query(x) << '\n';
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 3 ms 4204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 3 ms 4204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 3 ms 4204 KB Output isn't correct
3 Halted 0 ms 0 KB -