# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72171 | 2018-08-26T05:43:25 Z | 신딩없는 신딩팀(#2212, willi19, andy627, maruii) | 박스런 (FXCUP3_box) | C++17 | 170 ms | 7448 KB |
#include<bits/stdc++.h> using namespace std; int N,H[500005],dp[500005]; vector<pair<int,int> >stk; int main(){ scanf("%d",&N); for(int i=1;i<=N;i++) scanf("%d",H+i); stk.push_back({0,2e9}); fill(dp,dp+N+1,2e9); for(int i=1;i<=N;i++){ pair<int,int> cur={i,H[i]}; while(cur.second>stk.back().second)stk.pop_back(); int k=i-stk.back().first-1; dp[k]=min(dp[k],i); stk.push_back(cur); } for(int i=N-1;i;i--) dp[i]=min(dp[i+1],dp[i]); for(int i=1;i<=N;i++) printf("%d ",dp[i]==2e9?-1:dp[i]-i); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 436 KB | Output is correct |
4 | Correct | 2 ms | 436 KB | Output is correct |
5 | Correct | 2 ms | 488 KB | Output is correct |
6 | Correct | 3 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 520 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
10 | Correct | 2 ms | 664 KB | Output is correct |
11 | Correct | 2 ms | 664 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 436 KB | Output is correct |
4 | Correct | 2 ms | 436 KB | Output is correct |
5 | Correct | 2 ms | 488 KB | Output is correct |
6 | Correct | 3 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 520 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
10 | Correct | 2 ms | 664 KB | Output is correct |
11 | Correct | 2 ms | 664 KB | Output is correct |
12 | Correct | 2 ms | 664 KB | Output is correct |
13 | Correct | 4 ms | 720 KB | Output is correct |
14 | Correct | 25 ms | 1084 KB | Output is correct |
15 | Correct | 24 ms | 1528 KB | Output is correct |
16 | Correct | 35 ms | 1800 KB | Output is correct |
17 | Correct | 134 ms | 3976 KB | Output is correct |
18 | Correct | 119 ms | 5128 KB | Output is correct |
19 | Correct | 141 ms | 6432 KB | Output is correct |
20 | Correct | 152 ms | 7448 KB | Output is correct |
21 | Correct | 170 ms | 7448 KB | Output is correct |