結果

問題 No.930 数列圧縮
ユーザー vwxyzvwxyz
提出日時 2022-09-27 15:47:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 19,632 KB
最終ジャッジ日時 2023-08-24 03:54:32
合計ジャッジ時間 5,684 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,852 KB
testcase_01 WA -
testcase_02 AC 16 ms
7,772 KB
testcase_03 AC 16 ms
7,852 KB
testcase_04 WA -
testcase_05 AC 17 ms
8,372 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 106 ms
15,524 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 111 ms
16,344 KB
testcase_12 WA -
testcase_13 AC 31 ms
13,812 KB
testcase_14 AC 34 ms
15,396 KB
testcase_15 AC 144 ms
19,532 KB
testcase_16 AC 121 ms
19,548 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 149 ms
19,456 KB
testcase_20 WA -
testcase_21 AC 148 ms
19,584 KB
testcase_22 AC 15 ms
7,916 KB
testcase_23 AC 113 ms
19,444 KB
testcase_24 AC 16 ms
7,804 KB
testcase_25 AC 15 ms
7,768 KB
testcase_26 AC 15 ms
7,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
A=list(map(int,readline().split()))
if A[0]>A[1]:
    print("No")
else:
    print("Yes")
    queue=[]
    ans_lst=[]
    for a in A[1:-1]:
        queue.append(a)
        while len(queue)>=2 and queue[-2]<queue[-1]:
            x=queue.pop()
            ans_lst.append(queue.pop())
            queue.append(x)
    while queue and queue[-1]<A[-1]:
        ans_lst.append(queue.pop())
    ans_lst+=queue
    ans_lst.append(A[0])
    print(*ans_lst)
0