結果

問題 No.930 数列圧縮
ユーザー None
提出日時 2021-03-18 05:58:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 107,436 KB
最終ジャッジ日時 2024-11-15 23:49:04
合計ジャッジ時間 5,148 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int, input().split()))
if A[0]>A[-1]:
    print("No")
    exit()


# rank=[2,4,1,...]: A[2]<A[4]<A[1],...
rank,sortedA=zip(*sorted(enumerate(A),key=lambda x:x[1],reverse=True))

rank=list(rank)

res=[]
r=N-1
while rank:
    i=rank.pop()
    if i>=r:
        continue
    for a in A[i+1:r]:
        res.append(a)
    res.append(A[i])
    r=i


print("Yes")
print(*res)
0