# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95203 | easrui | Pyramid Base (IOI08_pyramid_base) | C++14 | 0 ms | 0 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.
void upt(int l, int r, int c, int s, int e, int pos)
{
if(e<l || s>r) return;
if(L[pos] && s!=e){
ST[2*pos] += L[pos];
ST[2*pos+1] += L[pos];
L[2*pos] += L[pos];
L[2*pos+1] += L[pos];
L[pos] = 0;
}
if(l<=s && e<=r){
ST[pos] += c;
L[pos] += c;
return;
}
int m = (s+e)/2;
upt(l,r,c,s,m,2*pos);
upt(l,r,c,m+1,e,2*pos+1);
}
int sum(int l, int r, int s, int e, int pos)
{
if(e<l || s>r) return 0;
if(L[pos] && s!=e){
ST[2*pos] += L[pos];
ST[2*pos+1] += L[pos];
L[2*pos] += L[pos];
L[2*pos+1] += L[pos];
L[pos] = 0;
}
if(l<=s && e<=r){
if(ST[pos]) return e-s+1;
}
if(s==e) return ST[pos];
int m = (s+e)/2;
return sum(l,r,s,m,2*pos) + sum(l,r,m+1,e,2*pos+1);
}