結果

問題 No.1708 Quality of Contest
ユーザー 👑 H20H20
提出日時 2021-10-15 22:47:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,197 ms / 2,000 ms
コード長 841 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 81,752 KB
実行使用メモリ 157,272 KB
最終ジャッジ日時 2023-10-17 20:41:10
合計ジャッジ時間 18,576 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,564 KB
testcase_01 AC 43 ms
55,564 KB
testcase_02 AC 43 ms
55,564 KB
testcase_03 AC 182 ms
78,640 KB
testcase_04 AC 212 ms
78,880 KB
testcase_05 AC 211 ms
79,476 KB
testcase_06 AC 170 ms
78,408 KB
testcase_07 AC 173 ms
78,360 KB
testcase_08 AC 43 ms
55,564 KB
testcase_09 AC 691 ms
157,272 KB
testcase_10 AC 474 ms
130,860 KB
testcase_11 AC 984 ms
136,672 KB
testcase_12 AC 1,053 ms
141,620 KB
testcase_13 AC 811 ms
125,008 KB
testcase_14 AC 1,094 ms
147,120 KB
testcase_15 AC 1,177 ms
141,496 KB
testcase_16 AC 974 ms
151,344 KB
testcase_17 AC 949 ms
144,040 KB
testcase_18 AC 967 ms
145,192 KB
testcase_19 AC 1,022 ms
147,708 KB
testcase_20 AC 863 ms
132,724 KB
testcase_21 AC 1,197 ms
149,664 KB
testcase_22 AC 1,089 ms
144,288 KB
testcase_23 AC 1,034 ms
138,444 KB
testcase_24 AC 599 ms
131,888 KB
testcase_25 AC 620 ms
132,152 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 = [(1,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