結果

問題 No.930 数列圧縮
ユーザー ああいい
提出日時 2022-01-01 21:05:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 20,812 KB
最終ジャッジ日時 2024-10-10 14:29:41
合計ジャッジ時間 4,055 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

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

import sys
if a[0] > a[-1]:
    print('No')
    exit()
print('Yes')

def calc(l,flag = True):
    if len(l) == 2:
        print(l[0])
        exit()
    s = []
    if flag:
        now = l[0]
        s.append(now)
        for i in range(1,len(l)-1):
            if l[i] > now:
                print(l[i],end = " ")
            else:
                s.append(l[i])
                now = l[i]
        s.append(l[-1])
        calc(s,False)
    else:
        now = l[-1]
        s.append(now)
        for i in reversed(range(1,len(l)-1)):
            if l[i] < now:
                print(l[i],end = " ")
            else:
                s.append(l[i])
                now = l[i]
        s.append(l[0])
        calc(s[::-1],True)
calc(a,True)
0