結果

問題 No.930 数列圧縮
ユーザー nep_pudding3nep_pudding3
提出日時 2019-11-22 23:12:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 619 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 82,796 KB
実行使用メモリ 222,772 KB
最終ジャッジ日時 2024-04-19 12:29:24
合計ジャッジ時間 7,657 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 33 ms
52,396 KB
testcase_07 AC 63 ms
77,524 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 44 ms
70,240 KB
testcase_14 AC 45 ms
71,640 KB
testcase_15 WA -
testcase_16 AC 343 ms
208,564 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 34 ms
53,820 KB
testcase_23 AC 256 ms
168,168 KB
testcase_24 AC 33 ms
53,136 KB
testcase_25 AC 32 ms
53,152 KB
testcase_26 AC 32 ms
52,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)

N = int(input())
a = list(map(int,input().split()))

if a[0] > a[-1]:
    print("No")
    exit()

print('Yes')

l = [i-1 for i in range(N)]
r = [i+1 for i in range(N)]
node = [0]*N
node[0] = 1
node[-1] = 1
ans = []

def func(x):
    if node[x]:
        return
    if a[l[x]] < a[x]:
        ans.append(a[x])
        node[x] = 1
        r[l[x]] = r[x]
        l[r[x]] = l[x]
    if a[x] < a[r[x]]:
        ans.append(a[x])
        node[x] = 1
        r[l[x]] = r[x]
        l[r[x]] = l[x]
        func(l[x])
    func(r[x])

func(1)
for i in ans:
    print(i,end=" ")
print(a[0])
0