結果

問題 No.1708 Quality of Contest
ユーザー chineristAC
提出日時 2020-09-13 01:59:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 740 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 59,120 KB
最終ジャッジ日時 2024-09-17 16:51:41
合計ジャッジ時間 12,558 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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