結果

問題 No.1373 Directed Operations
ユーザー donutholedonuthole
提出日時 2021-02-05 21:49:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 482 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 108,336 KB
最終ジャッジ日時 2023-09-15 08:00:50
合計ジャッジ時間 7,462 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,780 KB
testcase_01 AC 92 ms
71,624 KB
testcase_02 AC 173 ms
108,004 KB
testcase_03 AC 146 ms
108,156 KB
testcase_04 AC 144 ms
105,784 KB
testcase_05 AC 93 ms
71,888 KB
testcase_06 AC 482 ms
108,336 KB
testcase_07 AC 115 ms
77,760 KB
testcase_08 AC 136 ms
77,964 KB
testcase_09 AC 358 ms
106,036 KB
testcase_10 AC 309 ms
104,080 KB
testcase_11 AC 141 ms
78,768 KB
testcase_12 AC 306 ms
103,644 KB
testcase_13 AC 114 ms
77,504 KB
testcase_14 AC 480 ms
108,320 KB
testcase_15 AC 418 ms
104,440 KB
testcase_16 AC 479 ms
108,100 KB
testcase_17 AC 216 ms
100,324 KB
testcase_18 AC 138 ms
91,116 KB
testcase_19 AC 233 ms
87,992 KB
testcase_20 AC 297 ms
93,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import collections
import bisect


# sys.setrecursionlimit(10000001)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353


def ni(): return int(sys.stdin.buffer.readline())
def ns(): return map(int, sys.stdin.buffer.readline().split())
def na(): return list(map(int, sys.stdin.buffer.readline().split()))
def na1(): return list(map(lambda x: int(x)-1, sys.stdin.buffer.readline().split()))


# ===CODE===
def main():
    n = ni()
    a = na()

    a = [[ai, i, -1] for i, ai in enumerate(a)]
    a.sort()

    flg = True
    for i in range(2, n+1):
        if a[i-2][0] > i-1:
            flg = False
            break
        a[i-2][2] = i-a[i-2][0]

    if flg:
        print("YES")
        a.sort(key=lambda x: x[1])
        for ai, idx,res in a:
            print(res)
    else:
        print("NO")


if __name__ == '__main__':
    main()
0