結果
| 問題 | 
                            No.930 数列圧縮
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nep_pudding3
                         | 
                    
| 提出日時 | 2019-11-22 23:12:03 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 619 bytes | 
| コンパイル時間 | 189 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 222,208 KB | 
| 最終ジャッジ日時 | 2024-10-11 04:47:30 | 
| 合計ジャッジ時間 | 9,092 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 7 WA * 17 | 
ソースコード
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 = [i-1 for i in range(N)]
r = [i+1 for i in range(N)]
node = [0]*N
node[0] = 1
node[-1] = 1
ans = []
def func(x):
    if node[x]:
        return
    if a[l[x]] < a[x]:
        ans.append(a[x])
        node[x] = 1
        r[l[x]] = r[x]
        l[r[x]] = l[x]
    if a[x] < a[r[x]]:
        ans.append(a[x])
        node[x] = 1
        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])
            
            
            
        
            
nep_pudding3