Submission #68733

# Submission time Handle Problem Language Result Execution time Memory
68733 2018-08-18T10:00:43 Z 검수컵(#1978, imsifile) Box Run (FXCUP3_box) C++
100 / 100
206 ms 5532 KB
#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

box.cpp: In function 'int main()':
box.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
box.cpp:10:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a; scanf("%d", &a);
          ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 4 ms 500 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 3 ms 500 KB Output is correct
8 Correct 2 ms 524 KB Output is correct
9 Correct 2 ms 524 KB Output is correct
10 Correct 2 ms 524 KB Output is correct
11 Correct 3 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 4 ms 500 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 3 ms 500 KB Output is correct
8 Correct 2 ms 524 KB Output is correct
9 Correct 2 ms 524 KB Output is correct
10 Correct 2 ms 524 KB Output is correct
11 Correct 3 ms 524 KB Output is correct
12 Correct 3 ms 568 KB Output is correct
13 Correct 4 ms 596 KB Output is correct
14 Correct 21 ms 876 KB Output is correct
15 Correct 40 ms 1148 KB Output is correct
16 Correct 40 ms 1548 KB Output is correct
17 Correct 134 ms 2964 KB Output is correct
18 Correct 162 ms 3612 KB Output is correct
19 Correct 206 ms 4600 KB Output is correct
20 Correct 189 ms 5532 KB Output is correct
21 Correct 205 ms 5532 KB Output is correct