답안 #68711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68711 2018-08-18T08:51:53 Z imsifile 박스런 (FXCUP3_box) C++
0 / 100
3 ms 540 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(dap[i]>=0) fl=1;
		if(fl && dap[i]<0) 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);
          ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 540 KB Output is correct
4 Incorrect 2 ms 540 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 540 KB Output is correct
4 Incorrect 2 ms 540 KB Output isn't correct
5 Halted 0 ms 0 KB -