結果

問題 No.1373 Directed Operations
ユーザー 👑 tamatotamato
提出日時 2021-02-12 19:28:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 1,085 ms
コンパイル使用メモリ 87,508 KB
実行使用メモリ 94,996 KB
最終ジャッジ日時 2023-09-27 00:31:06
合計ジャッジ時間 5,322 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,548 KB
testcase_01 AC 74 ms
71,604 KB
testcase_02 AC 153 ms
94,612 KB
testcase_03 AC 90 ms
90,928 KB
testcase_04 AC 95 ms
91,316 KB
testcase_05 AC 73 ms
71,752 KB
testcase_06 AC 152 ms
94,996 KB
testcase_07 AC 94 ms
77,332 KB
testcase_08 AC 99 ms
79,472 KB
testcase_09 AC 116 ms
94,592 KB
testcase_10 AC 107 ms
92,888 KB
testcase_11 AC 92 ms
78,412 KB
testcase_12 AC 91 ms
89,164 KB
testcase_13 AC 77 ms
76,420 KB
testcase_14 AC 239 ms
94,984 KB
testcase_15 AC 226 ms
92,216 KB
testcase_16 AC 247 ms
94,864 KB
testcase_17 AC 172 ms
94,472 KB
testcase_18 AC 124 ms
87,532 KB
testcase_19 AC 169 ms
84,688 KB
testcase_20 AC 185 ms
87,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from heapq import heappop, heappush
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    cnt = [0] * N
    for a in A:
        cnt[a] += 1

    pq = []
    ans = [[] for _ in range(N)]
    for i in range(1, N):
        for _ in range(cnt[i]):
            heappush(pq, -i)
        if pq:
            a = -heappop(pq)
            ans[a].append(i + 1 - a)
        else:
            print("NO")
            exit()
    print("YES")
    for a in A:
        print(ans[a].pop())


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