結果
問題 |
No.1373 Directed Operations
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:35:40 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,157 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 61,832 KB |
最終ジャッジ日時 | 2025-06-12 21:37:42 |
合計ジャッジ時間 | 4,294 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | TLE * 1 -- * 18 |
ソースコード
def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 a_list = list(map(int, input[idx:idx + N-1])) reachable = {1} x_choices = [] for a in a_list: max_x = N - a if max_x < 1: print("NO") return sorted_reachable = sorted(reachable) found = False for x in sorted_reachable: if x > max_x: break new_node = x + a if new_node not in reachable: x_choices.append(x) reachable.add(new_node) found = True break if not found: if sorted_reachable[0] > max_x: print("NO") return x = sorted_reachable[0] new_node = x + a x_choices.append(x) if new_node not in reachable: reachable.add(new_node) if len(reachable) != N: print("NO") else: print("YES") for x in x_choices: print(x) if __name__ == "__main__": main()