# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68717 | imsifile | Box Run (FXCUP3_box) | C++98 | 222 ms | 5440 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<stdio.h>
int N, stk[505050][2], scn, dap[505050];
int main(){
scanf("%d", &N);
for(int i=1; i<=N; i++) dap[i]=-1;
stk[scn][0]=1<<30, stk[scn++][1]=-1;
for(int i=0; i<N; i++){
int a; scanf("%d", &a);
while(scn){
if(stk[scn-1][0] >= a) break;
scn--;
if(!scn) break;
int sz = i-stk[scn-1][1]-1;
if(dap[sz]<0) dap[sz]=i-sz+1;
}
stk[scn][0]=a, stk[scn][1]=i;
scn++;
}
int fl=0;
for(int i=N; i>=1; i--){
if(!fl){
if(dap[i]>=0) fl=1;
continue;
}
if(dap[i]<0 || dap[i]>dap[i+1]+1) dap[i]=dap[i+1]+1;
}
for(int i=1; i<=N; i++){
printf("%d", dap[i]);
if(i<N) printf(" ");
}
puts("");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |