結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,372 KB
testcase_01 AC 74 ms
71,356 KB
testcase_02 AC 71 ms
71,596 KB
testcase_03 AC 79 ms
71,416 KB
testcase_04 AC 73 ms
71,336 KB
testcase_05 AC 92 ms
76,940 KB
testcase_06 AC 73 ms
71,332 KB
testcase_07 AC 87 ms
76,764 KB
testcase_08 AC 112 ms
92,736 KB
testcase_09 AC 125 ms
93,084 KB
testcase_10 AC 117 ms
92,440 KB
testcase_11 AC 129 ms
88,452 KB
testcase_12 RE -
testcase_13 AC 128 ms
83,624 KB
testcase_14 AC 110 ms
84,776 KB
testcase_15 AC 119 ms
101,068 KB
testcase_16 AC 125 ms
103,204 KB
testcase_17 AC 131 ms
91,076 KB
testcase_18 AC 135 ms
90,968 KB
testcase_19 AC 132 ms
91,092 KB
testcase_20 AC 131 ms
90,972 KB
testcase_21 AC 128 ms
100,820 KB
testcase_22 AC 71 ms
71,420 KB
testcase_23 AC 119 ms
100,804 KB
testcase_24 AC 68 ms
71,420 KB
testcase_25 AC 70 ms
71,176 KB
testcase_26 AC 72 ms
71,460 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