This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |