結果

問題 No.1708 Quality of Contest
ユーザー FromBooskaFromBooska
提出日時 2024-03-18 13:13:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 417 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 156,720 KB
最終ジャッジ日時 2024-03-18 13:13:19
合計ジャッジ時間 10,398 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 39 ms
55,612 KB
testcase_03 AC 81 ms
76,928 KB
testcase_04 AC 81 ms
76,928 KB
testcase_05 AC 83 ms
76,680 KB
testcase_06 AC 81 ms
76,672 KB
testcase_07 AC 80 ms
76,672 KB
testcase_08 AC 39 ms
53,460 KB
testcase_09 AC 327 ms
156,720 KB
testcase_10 AC 262 ms
115,288 KB
testcase_11 AC 357 ms
137,468 KB
testcase_12 AC 368 ms
135,280 KB
testcase_13 AC 388 ms
138,992 KB
testcase_14 AC 358 ms
131,868 KB
testcase_15 AC 368 ms
133,312 KB
testcase_16 AC 366 ms
132,864 KB
testcase_17 AC 387 ms
153,492 KB
testcase_18 AC 360 ms
146,504 KB
testcase_19 AC 384 ms
145,668 KB
testcase_20 AC 403 ms
152,532 KB
testcase_21 AC 375 ms
125,992 KB
testcase_22 AC 355 ms
131,740 KB
testcase_23 AC 417 ms
133,096 KB
testcase_24 AC 279 ms
140,620 KB
testcase_25 AC 275 ms
139,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# ジャンルごとに降順ソートして1番にX点加算して全ソート

from collections import defaultdict

N, M, X = map(int, input().split())
dic = defaultdict(list)
for i in range(N):
    a, b = map(int, input().split())
    dic[b].append(a)

all_problems = []
for b in dic:
    dic[b].sort(reverse = True)
    dic[b][0] += X
    all_problems.extend(dic[b])

all_problems.sort(reverse = True)
#print(all_problems)

cumu = [0]
temp = 0
for i in range(N):
    temp += all_problems[i]
    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