# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334316 | nandonathaniel | Weighting stones (IZhO11_stones) | C++14 | 74 ms | 5612 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.
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
int tree[2][4*MAXN],lazy[2][4*MAXN];
void updatenode(int no,int now,int L,int R,int val){
tree[no][now]+=val;
lazy[no][now]+=val;
}
void pushdown(int no,int now,int L,int R){
int mid=(L+R)/2;
updatenode(no,2*now,L,mid,lazy[no][now]);
updatenode(no,2*now+1,mid+1,R,lazy[no][now]);
lazy[no][now]=0;
}
int query(int no,int now,int L,int R,int x,int y){
if(L>=x && R<=y)return tree[no][now];
if(L>y || R<x)return 0;
pushdown(no,now,L,R);
int mid=(L+R)/2;
return max(query(no,2*now,L,mid,x,y),query(no,2*now+1,mid+1,R,x,y));
}
void update(int now,int L,int R,int x,int y,int val){
if(L>=x && R<=y){
updatenode(0,now,L,R,val);
updatenode(1,now,L,R,val);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |