結果

問題 No.1708 Quality of Contest
ユーザー chineristAC
提出日時 2020-09-12 22:00:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 139,244 KB
最終ジャッジ日時 2024-09-17 16:50:19
合計ジャッジ時間 7,992 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline

N,M,X = map(int,input().split())
Genre = [[] for i in range(M)]
for _ in range(N):
    v,g = map(int,input().split())
    Genre[g-1].append(v)

K = int(input())
p = list(map(int,input().split()))

problem = []
for i in range(M):
    if Genre[i]:
        Genre[i].sort(reverse=True)
        Genre[i][0] += X
        problem += Genre[i]

problem.sort(reverse=True)
problem = [0] + problem
for i in range(1,N+1):
    problem[i] += problem[i-1]

ans = 0
for AC in p:
    ans += problem[AC]

print(ans)
0