結果

問題 No.1373 Directed Operations
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-02-05 22:07:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 537 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 99,296 KB
最終ジャッジ日時 2023-09-15 08:18:18
合計ジャッジ時間 9,350 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 76 ms
71,440 KB
testcase_02 AC 144 ms
97,936 KB
testcase_03 AC 115 ms
92,644 KB
testcase_04 AC 113 ms
93,496 KB
testcase_05 AC 72 ms
71,316 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 306 ms
93,644 KB
testcase_10 AC 269 ms
91,560 KB
testcase_11 AC 121 ms
78,932 KB
testcase_12 AC 263 ms
90,956 KB
testcase_13 AC 95 ms
76,972 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
a = list(map(int, input().split()))
a2 = [(a[i], i) for i in range(n - 1)]
a2.sort(reverse=True)
v = [0] * n
v[0] = 1
ans = [0] * (n - 1)
G = [[] for i in range(n)]
for i in range(n - 1):
    if a[a2[i][1]] + i < n:
        ans[a2[i][1]] = i + 1
        G[i].append(i + a2[i][0])
    else:
        exit(print("NO"))
def dfs(now):
    v[now] = 1
    for nex in G[now]:
        dfs(nex)
if all(v for i in range(n)):
    print("YES")
    print(*ans, sep="\n")
else:
    print("NO")
0