結果
| 問題 |
No.1708 Quality of Contest
|
| コンテスト | |
| ユーザー |
FromBooska
|
| 提出日時 | 2023-08-10 11:54:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 407 ms / 2,000 ms |
| コード長 | 750 bytes |
| コンパイル時間 | 390 ms |
| コンパイル使用メモリ | 82,208 KB |
| 実行使用メモリ | 156,992 KB |
| 最終ジャッジ日時 | 2024-11-16 16:52:01 |
| 合計ジャッジ時間 | 10,337 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
# 貪欲法
# 各ジャンルの最大クオリティにXを加算
# そのうえですべてをクオリティ降順で並べる
# そこから上位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)
problems = []
for b in genre:
genre[b].sort(reverse = True)
genre[b][0] += X
for a in genre[b]:
problems.append(a)
problems.sort(reverse = True)
#print(problems)
cumu = [0]
temp = 0
for p in problems:
temp += p
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