結果
問題 |
No.1373 Directed Operations
|
ユーザー |
![]() |
提出日時 | 2025-05-14 12:47:24 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 895 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 82,668 KB |
実行使用メモリ | 95,868 KB |
最終ジャッジ日時 | 2025-05-14 12:48:38 |
合計ジャッジ時間 | 4,377 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 TLE * 1 -- * 17 |
ソースコード
N = int(input()) a = list(map(int, input().split())) connected = [False] * (N + 2) # 1-based indexing connected[1] = True smallest_unconnected = 2 x_list = [] possible = True for ai in a: k = smallest_unconnected found = False while k <= N: if not connected[k]: x = k - ai if x >= 1 and connected[x]: connected[k] = True x_list.append(x) # Update smallest_unconnected while smallest_unconnected <= N and connected[smallest_unconnected]: smallest_unconnected += 1 found = True break else: k += 1 else: k += 1 if not found: possible = False break if possible and smallest_unconnected > N: print("YES") for x in x_list: print(x) else: print("NO")