#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |