#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const long long N = 1e5+10;
const long long mod = 1e9+7;
const long long inf = 1e18;
vector<int>ft(N);
void update(int index,int n,int val) {
while(index <= n) {
ft[index] += val;
index += index & -index;
}
}
int get(int x) {
int X = 0;
while(x >= 1) {
X += ft[x];
x -= x & -x;
}
return X;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,Q,k;
cin >> n >> Q >> k;
vector<int>a(n+1);
for(int i=1;i<=n;i++) {
cin >> a[i];
update(i,n,a[i]);
}
if(k == 1) {
while(Q--) {
int type;
cin >> type;
if(type == 1) {
int index,val;
cin >> index >> val;
update(index,n,val-a[index]);
a[index] = val;
}
else if(type == 2) {
int l,r;
cin >> l >> r;
}
else {
int l,r;
cin >> l >> r;
cout << get(r)-get(l-1);
}
}
return 0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
3760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
2260 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |