結果

問題 No.1708 Quality of Contest
ユーザー FromBooska
提出日時 2024-03-18 13:13:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 157,512 KB
最終ジャッジ日時 2024-09-30 04:54:28
合計ジャッジ時間 8,728 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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