답안 #72170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72170 2018-08-26T05:43:21 Z ㅋ(#2245, dohyun0324) 박스런 (FXCUP3_box) C++17
100 / 100
197 ms 9088 KB
#include<stdio.h>
int top,arr[500010],n,a[500010],st[500010],c,dap[500010];
int main()
{
    int i,j;
    //freopen("input.txt","r",stdin);
    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    {
        while(top)
        {
            if(a[st[top]]>=a[i]) break;
            top--;
        }
        arr[i-1]=i-st[top]-1;
        st[++top]=i;
    }
    c=1;
    for(i=1;i<=n-1;i++)
    {
        if(c>arr[i]) continue;
        for(j=c;j<=arr[i];j++)
        {
            dap[j]=i-j+1;
        }
        c=arr[i]+1;
    }
    for(i=1;i<=n;i++)
    {
        if(dap[i]==0) printf(" -1");
        else printf("%d ",dap[i]);
    }
    return 0;
}

Compilation message

box.cpp: In function 'int main()':
box.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
box.cpp:8:28: 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",&a[i]);
                       ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 3 ms 488 KB Output is correct
9 Correct 3 ms 564 KB Output is correct
10 Correct 3 ms 564 KB Output is correct
11 Correct 3 ms 596 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 412 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 3 ms 488 KB Output is correct
9 Correct 3 ms 564 KB Output is correct
10 Correct 3 ms 564 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 14 ms 1236 KB Output is correct
15 Correct 34 ms 1764 KB Output is correct
16 Correct 45 ms 2164 KB Output is correct
17 Correct 90 ms 4868 KB Output is correct
18 Correct 120 ms 5892 KB Output is correct
19 Correct 134 ms 7564 KB Output is correct
20 Correct 197 ms 9088 KB Output is correct
21 Correct 169 ms 9088 KB Output is correct