結果

問題 No.1708 Quality of Contest
ユーザー 👑 H20H20
提出日時 2021-10-15 22:43:12
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 840 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 157,400 KB
最終ジャッジ日時 2023-10-17 20:38:59
合計ジャッジ時間 18,871 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,688 KB
testcase_01 AC 43 ms
55,688 KB
testcase_02 AC 44 ms
55,688 KB
testcase_03 AC 177 ms
78,872 KB
testcase_04 AC 208 ms
79,024 KB
testcase_05 AC 205 ms
79,464 KB
testcase_06 AC 163 ms
78,524 KB
testcase_07 AC 170 ms
78,496 KB
testcase_08 AC 43 ms
55,688 KB
testcase_09 AC 676 ms
157,400 KB
testcase_10 AC 468 ms
130,992 KB
testcase_11 AC 954 ms
136,804 KB
testcase_12 AC 1,059 ms
141,760 KB
testcase_13 AC 777 ms
125,092 KB
testcase_14 AC 1,092 ms
147,240 KB
testcase_15 AC 1,239 ms
141,624 KB
testcase_16 AC 961 ms
151,476 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 1,190 ms
149,796 KB
testcase_22 AC 1,226 ms
143,592 KB
testcase_23 AC 1,014 ms
138,572 KB
testcase_24 AC 592 ms
132,020 KB
testcase_25 AC 608 ms
132,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq 
import itertools
import collections

d = collections.defaultdict(list)

N,M,X = map(int, input().split())
for i in range(N):
    a,b = map(int, input().split())
    heapq.heappush(d[b],-a)

MQ = [(0,0)]
for k,v in d.items():
    q = heapq.heappop(v)
    heapq.heappush(MQ, (q,k))  


USED = [0]
K = int(input())
C = list(map(int, input().split()))
CNT = [0]*(N+2)
CNT[0] = K
for c in C:
    CNT[c+1]-=1
AC = list(itertools.accumulate(CNT))
ans = 0
for i in range(1,N+1):
    mused = heapq.heappop(USED)
    mqq,mqk = heapq.heappop(MQ)

    if mqk != 0 and mused>mqq-X:
        ans -= (mqq-X)*AC[i]
        heapq.heappush(USED, mused)
        while len(d[mqk]):
            temp = heapq.heappop(d[mqk])
            heapq.heappush(USED, temp)
    else:
        ans -= mused*AC[i]
        heapq.heappush(MQ, (mqq,mqk))
print(ans)
0