結果

問題 No.1373 Directed Operations
ユーザー wotsushiwotsushi
提出日時 2020-11-04 22:12:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 301 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 10,656 KB
実行使用メモリ 27,560 KB
最終ジャッジ日時 2023-09-29 16:21:46
合計ジャッジ時間 4,943 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
9,044 KB
testcase_01 AC 25 ms
9,044 KB
testcase_02 AC 204 ms
24,204 KB
testcase_03 AC 101 ms
24,280 KB
testcase_04 AC 116 ms
24,452 KB
testcase_05 AC 25 ms
9,048 KB
testcase_06 AC 279 ms
24,812 KB
testcase_07 AC 30 ms
9,616 KB
testcase_08 AC 48 ms
10,896 KB
testcase_09 AC 212 ms
24,636 KB
testcase_10 AC 162 ms
22,216 KB
testcase_11 AC 57 ms
12,524 KB
testcase_12 AC 144 ms
21,832 KB
testcase_13 AC 39 ms
10,928 KB
testcase_14 AC 301 ms
27,560 KB
testcase_15 AC 247 ms
25,184 KB
testcase_16 AC 285 ms
27,504 KB
testcase_17 AC 173 ms
20,792 KB
testcase_18 AC 102 ms
15,920 KB
testcase_19 AC 113 ms
15,224 KB
testcase_20 AC 151 ms
18,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import re

lines = []
for line in sys.stdin:
    lines.append(line)
pos_int = r"[1-9]\d*"
assert len(lines) == 2
assert re.fullmatch(fr"{pos_int}\n", lines[0])
N = int(lines[0])
assert 2 <= N <= 10 ** 5
assert re.fullmatch(fr"({pos_int} )*{pos_int}\n", lines[1])
a = list(map(int, lines[1].split()))
assert len(a) == N - 1
assert all(1 <= a[i] <= N - 1 for i in range(N - 1))

p = [(0, 0)] + sorted((x, i) for i, x in enumerate(a, 1))
x = [0 for _ in range(N)]
for i in range(1, N):
    if p[i][0] > i:
        print("NO")
        exit()
    x[p[i][1]] = (i + 1) - p[i][0]
print("YES")
for i in range(1, N):
    print(x[i])
0