# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173149 | juggernaut | Trading (IZhO13_trading) | C++14 | 263 ms | 10708 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.
//Just try and the idea will come!
#include<bits/stdc++.h>
using namespace std;
int flag[1200001],n,m,x,y,z;
void update(int v,int l,int r,int ql,int qr,int val){
if(r<ql||qr<l)return;
if(ql<=l&&r<=qr){
flag[v]=max(flag[v],val);
return;
}
int mid=(l+r)>>1;
update((v<<1),l,mid,ql,qr,val);
update((v<<1)+1,mid+1,r,ql,qr,val+mid-l+1);
}
void push(int v,int l,int r){
int mid=(l+r)>>1;
if(l!=r){
if(flag[v]){
flag[(v<<1)]=max(flag[(v<<1)],flag[v]);
flag[(v<<1)+1]=max(flag[(v<<1)+1],flag[v]+mid-l+1);
}
}else{
printf("%d ",flag[v]);
return;
}
push((v<<1),l,mid);
push((v<<1)+1,mid+1,r);
}
int main(){
scanf("%d%d",&n,&m);
while(m--){
scanf("%d%d%d",&x,&y,&z);
update(1,1,n,x,y,z-x+1);
}
push(1,1,n);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |