結果

問題 No.930 数列圧縮
ユーザー rlangevinrlangevin
提出日時 2023-09-28 08:57:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 19,636 KB
最終ジャッジ日時 2023-09-28 08:57:53
合計ジャッジ時間 3,957 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,764 KB
testcase_01 AC 14 ms
7,764 KB
testcase_02 AC 13 ms
7,824 KB
testcase_03 AC 14 ms
7,756 KB
testcase_04 AC 13 ms
7,800 KB
testcase_05 AC 14 ms
8,248 KB
testcase_06 AC 14 ms
7,892 KB
testcase_07 AC 17 ms
8,564 KB
testcase_08 AC 77 ms
15,704 KB
testcase_09 AC 126 ms
17,320 KB
testcase_10 AC 79 ms
15,464 KB
testcase_11 AC 82 ms
16,288 KB
testcase_12 AC 98 ms
17,372 KB
testcase_13 AC 53 ms
13,868 KB
testcase_14 AC 59 ms
15,376 KB
testcase_15 AC 102 ms
19,436 KB
testcase_16 AC 118 ms
19,448 KB
testcase_17 AC 114 ms
19,476 KB
testcase_18 AC 132 ms
19,508 KB
testcase_19 AC 117 ms
19,508 KB
testcase_20 AC 110 ms
19,484 KB
testcase_21 AC 107 ms
19,636 KB
testcase_22 AC 13 ms
7,792 KB
testcase_23 AC 99 ms
19,516 KB
testcase_24 AC 13 ms
7,724 KB
testcase_25 AC 13 ms
7,764 KB
testcase_26 AC 13 ms
7,864 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