結果
| 問題 |
No.1373 Directed Operations
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:16:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 730 bytes |
| コンパイル時間 | 286 ms |
| コンパイル使用メモリ | 82,180 KB |
| 実行使用メモリ | 106,272 KB |
| 最終ジャッジ日時 | 2025-06-12 19:16:45 |
| 合計ジャッジ時間 | 4,320 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 TLE * 1 -- * 17 |
ソースコード
import heapq
n = int(input())
a = list(map(int, input().split()))
reachable = [False] * (n + 1)
reachable[1] = True
unreachable = list(range(2, n + 1))
heapq.heapify(unreachable)
result = []
possible = True
for ai in a:
temp = []
found = False
while unreachable:
s = heapq.heappop(unreachable)
x = s - ai
if x >= 1 and reachable[x]:
reachable[s] = True
result.append(x)
found = True
break
else:
temp.append(s)
if not found:
possible = False
break
for node in temp:
heapq.heappush(unreachable, node)
if possible:
print("YES")
for x in result:
print(x)
else:
print("NO")
gew1fw