結果

問題 No.1373 Directed Operations
ユーザー FromBooskaFromBooska
提出日時 2023-04-19 18:17:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 511 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 102,912 KB
最終ジャッジ日時 2024-04-22 19:26:13
合計ジャッジ時間 7,787 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 42 ms
52,096 KB
testcase_02 AC 166 ms
102,732 KB
testcase_03 AC 101 ms
102,912 KB
testcase_04 AC 101 ms
102,108 KB
testcase_05 AC 40 ms
51,968 KB
testcase_06 AC 473 ms
102,152 KB
testcase_07 AC 61 ms
65,664 KB
testcase_08 AC 96 ms
77,824 KB
testcase_09 AC 359 ms
101,956 KB
testcase_10 AC 300 ms
100,056 KB
testcase_11 AC 100 ms
78,844 KB
testcase_12 AC 302 ms
99,456 KB
testcase_13 AC 69 ms
69,120 KB
testcase_14 AC 511 ms
102,012 KB
testcase_15 AC 429 ms
100,352 KB
testcase_16 AC 499 ms
102,012 KB
testcase_17 AC 179 ms
96,116 KB
testcase_18 AC 97 ms
88,884 KB
testcase_19 AC 209 ms
85,080 KB
testcase_20 AC 268 ms
89,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 頂点1スタートで頂点2に達するためには絶対にa=1が必要
# 上の条件を満たしたとして、頂点2に達するためにはa = 1 or 2が必要
# その繰り返し
# Aをソートして、前から1以下、2以下、3以下、と確認

N = int(input())
A = list(map(int, input().split()))
A_with_idx = []
for i in range(N-1):
    A_with_idx.append([A[i], i])
A_with_idx.sort()    

ans = 'YES'
for i in range(N-1):
    if A_with_idx[i][0] >= i+2:
        ans = 'NO'
    else:
        A_with_idx[i].append(i+2-A_with_idx[i][0])
#print(A_with_idx)

if ans == 'NO':
    print(ans)
else:
    print(ans)
    A_with_idx.sort(key = lambda x:x[1])
    for i in range(N-1):
        print(A_with_idx[i][2])
0