Submission #341366

#TimeUsernameProblemLanguageResultExecution timeMemory
341366nandonathanielSimple game (IZhO17_game)C++14
0 / 100
3 ms4204 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...