結果

問題 No.1373 Directed Operations
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-02-05 22:31:14
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 355 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 28,944 KB
最終ジャッジ日時 2023-09-15 08:57:29
合計ジャッジ時間 4,552 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,960 KB
testcase_01 AC 15 ms
8,180 KB
testcase_02 AC 150 ms
25,416 KB
testcase_03 AC 112 ms
23,040 KB
testcase_04 AC 45 ms
19,684 KB
testcase_05 AC 16 ms
7,808 KB
testcase_06 AC 231 ms
25,832 KB
testcase_07 AC 19 ms
8,732 KB
testcase_08 AC 34 ms
10,396 KB
testcase_09 AC 45 ms
19,664 KB
testcase_10 AC 40 ms
17,976 KB
testcase_11 AC 22 ms
10,612 KB
testcase_12 AC 120 ms
20,748 KB
testcase_13 AC 19 ms
9,372 KB
testcase_14 AC 280 ms
28,852 KB
testcase_15 AC 223 ms
26,164 KB
testcase_16 AC 277 ms
28,944 KB
testcase_17 AC 135 ms
21,420 KB
testcase_18 AC 76 ms
16,084 KB
testcase_19 AC 92 ms
15,204 KB
testcase_20 AC 129 ms
17,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
if not n - 1 <= sum(a) <= n * (n - 1) // 2:
    exit(print("NO"))
a2 = [(a[i], i) for i in range(n - 1)]
a2.sort()
ans = [0] * (n - 1)
for i in range(1, n)[::-1]:
    ans[a2[i - 1][1]] = i - a2[i - 1][0] + 1
    if i - a2[i - 1][0] + 1 <= 0:
        exit(print("NO"))
print("YES")
print(*ans, sep="\n")
0