結果

問題 No.930 数列圧縮
ユーザー rlangevinrlangevin
提出日時 2023-09-28 08:58:24
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 387 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 103,356 KB
最終ジャッジ日時 2023-09-28 08:58:32
合計ジャッジ時間 6,789 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,236 KB
testcase_01 AC 77 ms
71,228 KB
testcase_02 AC 78 ms
71,568 KB
testcase_03 AC 77 ms
71,452 KB
testcase_04 AC 80 ms
71,528 KB
testcase_05 AC 98 ms
76,808 KB
testcase_06 AC 77 ms
71,392 KB
testcase_07 AC 94 ms
76,896 KB
testcase_08 AC 119 ms
92,716 KB
testcase_09 AC 130 ms
92,836 KB
testcase_10 AC 140 ms
92,580 KB
testcase_11 AC 124 ms
88,504 KB
testcase_12 RE -
testcase_13 AC 110 ms
83,472 KB
testcase_14 AC 117 ms
85,088 KB
testcase_15 AC 126 ms
100,936 KB
testcase_16 AC 132 ms
103,356 KB
testcase_17 AC 142 ms
90,840 KB
testcase_18 AC 144 ms
90,876 KB
testcase_19 AC 143 ms
90,868 KB
testcase_20 AC 141 ms
90,952 KB
testcase_21 AC 138 ms
100,724 KB
testcase_22 AC 75 ms
71,644 KB
testcase_23 AC 124 ms
101,076 KB
testcase_24 AC 78 ms
71,444 KB
testcase_25 AC 84 ms
71,644 KB
testcase_26 AC 76 ms
71,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
stack = [A[0]]
ans = []
for i in range(1, N):
    while len(stack) >= 2:
        if stack[-1] < A[i]:
            ans.append(stack.pop())
        else:
            break
    if stack[-1] < A[i]:
        ans.append(A[i])
    else:
        stack.append(A[i])

if len(ans) == N - 1:
    print("Yes")
    print(*ans)
else:
    print("No")
0