이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |