結果
| 問題 |
No.1708 Quality of Contest
|
| コンテスト | |
| ユーザー |
FromBooska
|
| 提出日時 | 2023-05-19 18:18:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 383 ms / 2,000 ms |
| コード長 | 881 bytes |
| コンパイル時間 | 364 ms |
| コンパイル使用メモリ | 82,164 KB |
| 実行使用メモリ | 151,740 KB |
| 最終ジャッジ日時 | 2024-12-18 00:29:36 |
| 合計ジャッジ時間 | 9,658 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
# 新ジャンルボーナスを各ジャンルごとの最高点のものにX点加算
# それからK回ナップザックをやったら間に合わない
# ナップザックをやらずに貪欲法、最高値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)
all_list = []
for g in genre:
temp = sorted(genre[g], reverse = True)
for i in range(len(temp)):
if i == 0:
all_list.append(temp[i]+X)
else:
all_list.append(temp[i])
all_list.sort(reverse = True)
#print(all_list)
cumu = [0]
temp = 0
for i in range(N):
temp += all_list[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)
FromBooska