# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72222 | 김동현보다 잘함 (#118) | 박스런 (FXCUP3_box) | C++17 | 176 ms | 7344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |