# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74980 | Vardanyan | Weighting stones (IZhO11_stones) | C++14 | 113 ms | 15172 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
const int N = 100*1000+7;
pair<int,int> t[4*N];
int f[4*N];
void push(int v, int s, int e) {
if (f[v]) {
t[v].first += (1*f[v]);
t[v].second += (1*f[v]);
if (s != e) {
f[v*2] += f[v];
f[v*2 + 1] += f[v];
}
f[v] = 0;
}
}
void update(int v, int s, int e, int l, int r, int val) {
push(v, s, e);
if(l>r) return;
if (s == l && e == r) {
f[v] += val;
push(v, s, e);
return;
}
int m = (s + e) / 2;
update(v*2, s, m, l, min(m,r), val);
update(v*2 + 1, m + 1, e, max(l,m+1), r, val);
push(v*2,s,m);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |