結果

問題 No.1708 Quality of Contest
ユーザー FromBooskaFromBooska
提出日時 2023-08-10 11:54:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 157,000 KB
最終ジャッジ日時 2024-04-28 05:13:28
合計ジャッジ時間 9,020 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,504 KB
testcase_01 AC 42 ms
53,504 KB
testcase_02 AC 50 ms
53,632 KB
testcase_03 AC 77 ms
77,312 KB
testcase_04 AC 101 ms
76,800 KB
testcase_05 AC 79 ms
76,928 KB
testcase_06 AC 75 ms
77,056 KB
testcase_07 AC 75 ms
76,928 KB
testcase_08 AC 38 ms
53,760 KB
testcase_09 AC 294 ms
157,000 KB
testcase_10 AC 245 ms
123,372 KB
testcase_11 AC 325 ms
136,780 KB
testcase_12 AC 344 ms
130,172 KB
testcase_13 AC 302 ms
139,920 KB
testcase_14 AC 331 ms
125,348 KB
testcase_15 AC 336 ms
134,168 KB
testcase_16 AC 347 ms
132,504 KB
testcase_17 AC 316 ms
145,268 KB
testcase_18 AC 318 ms
143,660 KB
testcase_19 AC 328 ms
137,720 KB
testcase_20 AC 308 ms
145,068 KB
testcase_21 AC 328 ms
128,588 KB
testcase_22 AC 332 ms
125,096 KB
testcase_23 AC 339 ms
133,160 KB
testcase_24 AC 270 ms
143,316 KB
testcase_25 AC 270 ms
143,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 貪欲法
# 各ジャンルの最大クオリティにXを加算
# そのうえですべてをクオリティ降順で並べる
# そこから上位C個を取ればいい、累積和

N, M, X = map(int, input().split())
from collections import defaultdict
genre = defaultdict(list)
for i in range(N):
    a, b = map(int, input().split())
    genre[b].append(a)
problems = []
for b in genre:
    genre[b].sort(reverse = True)
    genre[b][0] += X
    for a in genre[b]:
        problems.append(a)
problems.sort(reverse = True)
#print(problems)

cumu = [0]
temp = 0
for p in problems:
    temp += p
    cumu.append(temp)
    
#print(cumu)

K = int(input())
C = list(map(int, input().split()))
ans = 0
for c in C:
    ans += cumu[c]
print(ans)







0