제출 #72222

#제출 시각아이디문제언어결과실행 시간메모리
72222김동현보다 잘함 (#118)박스런 (FXCUP3_box)C++17
100 / 100
176 ms7344 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; int n; int INF = 1e9; int arr[500100]; int ans[500100]; int main() { int i; scanf("%d",&n); for (i=0;i<=n;i++) ans[i] = INF; stack<int> st; st.push(0); arr[0] = 1e9+10; for (i=1;i<=n;i++) { scanf("%d",&arr[i]); while(arr[st.top()]<arr[i]) st.pop(); ans[i-st.top()-1] = min(ans[i-st.top()-1],i); st.push(i); } for (i=n-1;i>=0;i--) ans[i] = min(ans[i],ans[i+1]); for (i=1;i<=n;i++) printf("%d ",ans[i]>n?-1:ans[i]-i); return 0; }

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

box.cpp: In function 'int main()':
box.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
box.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...