結果

問題 No.1708 Quality of Contest
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 18:18:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 148,128 KB
最終ジャッジ日時 2023-08-22 22:03:54
合計ジャッジ時間 12,078 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,472 KB
testcase_01 AC 94 ms
71,288 KB
testcase_02 AC 94 ms
71,392 KB
testcase_03 AC 192 ms
77,812 KB
testcase_04 AC 140 ms
77,912 KB
testcase_05 AC 137 ms
77,900 KB
testcase_06 AC 139 ms
77,732 KB
testcase_07 AC 140 ms
77,732 KB
testcase_08 AC 94 ms
71,336 KB
testcase_09 AC 366 ms
145,528 KB
testcase_10 AC 320 ms
145,840 KB
testcase_11 AC 406 ms
123,944 KB
testcase_12 AC 409 ms
128,044 KB
testcase_13 AC 398 ms
134,864 KB
testcase_14 AC 439 ms
130,728 KB
testcase_15 AC 427 ms
148,128 KB
testcase_16 AC 433 ms
141,776 KB
testcase_17 AC 421 ms
126,848 KB
testcase_18 AC 410 ms
127,824 KB
testcase_19 AC 411 ms
134,936 KB
testcase_20 AC 408 ms
126,644 KB
testcase_21 AC 420 ms
143,064 KB
testcase_22 AC 419 ms
132,976 KB
testcase_23 AC 434 ms
142,404 KB
testcase_24 AC 332 ms
126,104 KB
testcase_25 AC 332 ms
125,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 新ジャンルボーナスを各ジャンルごとの最高点のものに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)
0