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