結果
問題 |
No.930 数列圧縮
|
ユーザー |
![]() |
提出日時 | 2019-11-22 23:03:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 562 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 81,968 KB |
実行使用メモリ | 212,304 KB |
最終ジャッジ日時 | 2024-10-11 04:40:59 |
合計ジャッジ時間 | 5,401 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 1 WA * 6 TLE * 1 -- * 16 |
ソースコード
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])