# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
170826 | ZwariowanyMarcin | Sterilizing Spray (JOI15_sterilizing) | C++14 | 298 ms | 9252 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)
using namespace std;
const int nax = 1e5 + 111;
struct fen {
ll t[nax];
void init() {
for(int i = 0; i < nax; ++i)
t[i] = 0;
}
void add(int x, int c) {
for(;x < nax; x += x & -x)
t[x] += c;
}
ll query(int x) {
ll res = 0;
for(; 0 < x; x -= x & -x)
res += t[x];
return res;
}
ll sum(int l, int r) {
return query(r) - query(l - 1);
}
} ja;
set <int> secik;
int n, q, k;
int a[nax];
vector <int> del;
int main() {
ja.init();
scanf("%d %d %d", &n, &q, &k);
for(int i = 1; i <= n; ++i) {
scanf("%d", a + i);
secik.insert(i);
ja.add(i, a[i]);
}
for(int i = 1; i <= q; ++i) {
int type, l, r;
scanf("%d %d %d", &type, &l, &r);
if(type == 1) {
if(!a[l]) secik.insert(l);
ja.add(l, -a[l]);
a[l] = r;
ja.add(l, a[l]);
}
if(type == 2) {
if(k == 1) continue;
auto it = secik.lower_bound(l);
while(it != secik.end() && *it <= r) {
int diff = a[*it] - a[*it] / k;
ja.add(*it, -diff);
a[*it] += -diff;
if(a[*it] == 0)
del.pb(*it);
it++;
}
for(auto it : del)
secik.erase(it);
del.clear();
}
if(type == 3) {
printf("%lld\n", ja.sum(l, r));
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |