結果

問題 No.1373 Directed Operations
ユーザー tamatotamato
提出日時 2021-02-12 19:28:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 99,712 KB
最終ジャッジ日時 2024-07-19 18:10:14
合計ジャッジ時間 3,700 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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