結果

問題 No.930 数列圧縮
ユーザー nep_pudding3
提出日時 2019-11-22 23:01:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 66,464 KB
最終ジャッジ日時 2024-10-11 04:36:54
合計ジャッジ時間 5,381 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 1 WA * 6 TLE * 1 -- * 16
権限があれば一括ダウンロードができます

ソースコード

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 = [0]+[i for i in range(N-1)]
r = [i for i in range(1,N)]+[N-1]
ans = []

def func(x):
    if x == 0 or x == N-1:
        return
    if a[l[x]] < a[x]:
        ans.append(a[x])
        r[l[x]] = r[x]
        l[r[x]] = l[x]
    if a[x] < a[r[x]]:
        ans.append(a[x])
        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