제출 #72002

#제출 시각아이디문제언어결과실행 시간메모리
72002----------넘사벽---------- (#118)Box Run (FXCUP3_box)C++11
100 / 100
180 ms5564 KiB
#include<bits/stdc++.h>
#define N 500005

using namespace std;
typedef pair<int, int> pp;

int h[N];

stack<pp> st;

int main(){
	int n, i;
	scanf("%d", &n);
	for(i=1;i<=n;i++) scanf("%d", h+i);
	st.push(pp(0, INT_MAX));
	int c=1;
	for(i=1;i<=n;i++){
		while(!st.empty()&&st.top().second<h[i]) st.pop();
		while(c<i-st.top().first){
			//printf("%d ", i);
			printf("%d ", i-c);
			c++;
		}
		st.push(pp(i, h[i]));
	}
	while(c<=n){printf("-1 ");c++;}
	printf("\n");
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

box.cpp: In function 'int main()':
box.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
box.cpp:14:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) scanf("%d", h+i);
                    ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...