Submission #72222

# Submission time Handle Problem Language Result Execution time Memory
72222 2018-08-26T06:07:27 Z 김동현보다 잘함(#2226, tlwpdus) Box Run (FXCUP3_box) C++17
100 / 100
176 ms 7344 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 2 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 2 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 3 ms 572 KB Output is correct
13 Correct 3 ms 576 KB Output is correct
14 Correct 16 ms 1092 KB Output is correct
15 Correct 41 ms 1508 KB Output is correct
16 Correct 43 ms 1764 KB Output is correct
17 Correct 80 ms 3940 KB Output is correct
18 Correct 108 ms 4964 KB Output is correct
19 Correct 143 ms 6372 KB Output is correct
20 Correct 176 ms 7344 KB Output is correct
21 Correct 167 ms 7344 KB Output is correct