結果

問題 No.930 数列圧縮
ユーザー Kyo ArayamaKyo Arayama
提出日時 2019-11-24 16:44:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 575 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 24,236 KB
最終ジャッジ日時 2024-04-20 08:56:18
合計ジャッジ時間 5,378 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 31 ms
10,752 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 599 ms
11,008 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N = int(input())
    a = [int(x) for x in input().split(" ")]

    last = a.pop()
    cnt = sum([x < y for x, y in zip(a, a[1:])])

    if last < N - cnt:
        print("No")
        return
    print("Yes")
    res = []
    for _ in range(cnt):
        for i, v in enumerate(zip(a, a[1:])):
            x, y = v
            if x > y:
                continue
            if last < y:
                res.append(a.pop(i+1))
                break
    res += list(reversed(a))
    print(" ".join([str(x) for x in res]))


if __name__ == "__main__":
    solve()
0