結果

問題 No.930 数列圧縮
ユーザー maspy
提出日時 2020-02-26 17:02:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,956 KB
最終ジャッジ日時 2024-10-13 15:26:02
合計ジャッジ時間 3,903 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
N, *A = map(int, read().split())

# %%
if A[0] > A[-1]:
    print('No')
    exit()

# %%
rest = [A[0]]
remove = []
for x in A[1:-1]:
    if x > rest[-1]:
        remove.append(x)
    else:
        rest.append(x)

# %%
for x in rest[::-1]:
    remove.append(x)

# %%
print('Yes')
print(' '.join(map(str, remove)))
0