結果

問題 No.930 数列圧縮
ユーザー 👑 H20H20
提出日時 2022-01-14 11:57:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 90,752 KB
最終ジャッジ日時 2024-04-29 19:08:38
合計ジャッジ時間 5,330 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,632 KB
testcase_01 AC 46 ms
53,504 KB
testcase_02 AC 47 ms
53,632 KB
testcase_03 AC 47 ms
53,888 KB
testcase_04 AC 50 ms
54,656 KB
testcase_05 AC 64 ms
65,152 KB
testcase_06 AC 47 ms
53,888 KB
testcase_07 AC 76 ms
70,144 KB
testcase_08 AC 107 ms
86,016 KB
testcase_09 AC 124 ms
86,656 KB
testcase_10 AC 123 ms
84,736 KB
testcase_11 AC 113 ms
85,248 KB
testcase_12 AC 121 ms
87,936 KB
testcase_13 AC 69 ms
70,784 KB
testcase_14 AC 65 ms
72,192 KB
testcase_15 AC 117 ms
90,752 KB
testcase_16 AC 158 ms
90,752 KB
testcase_17 AC 132 ms
89,984 KB
testcase_18 AC 127 ms
90,112 KB
testcase_19 AC 137 ms
89,984 KB
testcase_20 AC 138 ms
89,856 KB
testcase_21 AC 125 ms
89,984 KB
testcase_22 AC 46 ms
53,376 KB
testcase_23 AC 111 ms
90,496 KB
testcase_24 AC 46 ms
53,120 KB
testcase_25 AC 47 ms
53,376 KB
testcase_26 AC 46 ms
53,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N = int(input())
A = list(map(int,input().split()))
if A[0]>A[-1]:
    print('No')
    exit()
print('Yes')
d = collections.deque()
ANS = []
for a in A:
    d.append(a)
    while len(d)>1 and d[-2]<d[-1]:
        if d[-2]<d[-1] and len(d)>2:
            v = d.pop()
            v2 = d.pop()
            ANS.append(v2)
            d.append(v)
        if d[-2]<d[1] and len(d)==2:
            v = d.pop()
            ANS.append(v)
print(*ANS)
0