#pragma GCC optimize("O3,Ofast,unroll-loops")
#include "bits/stdc++.h"
const int MOD = 1e9 + 7;
using namespace std;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define ll long long
#define S second
#define F first
vector<ll> tree;
ll N;
void init(ll n) {
N = 1 << (ll)ceil(log2(n));
tree.resize(N * 2, 0);
}
void upd(ll id, ll val) {
id += N;
tree[id] = val;
while (id /= 2) {
tree[id] = tree[id * 2] + tree[id * 2 + 1];
}
}
int query(ll id, ll l, ll r, ll s, ll e) {
if (s <= l && r <= e) return tree[id];
if (l > e || r < s) return 0;
int m = (l + r) / 2;
return query(id * 2, l, m, s, e) + query(id * 2 + 1, m + 1, r, s, e);
}
void solve() {
int n, q, k;
cin >> n >> q >> k;
vi c(n + 1); init(n + 1);
for (int i = 1; i <= n; i++) {
cin >> c[i];
upd(i, c[i]);
}
while (q--) {
int s, t, u;
cin >> s >> t >> u;
if (s == 1) {
c[t] = u;
upd(t, u);
}
else if (s == 2) {
if (k != 1) {
tree.resize(N * 2, 0);
}
}
else {
cout << query(1, 0, N - 1, t, u) << endl;
}
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
while (t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
82 ms |
3176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
53 ms |
2904 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |