結果

問題 No.1947 質より種類数
ユーザー ああいいああいい
提出日時 2022-05-21 00:13:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 814 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 78,752 KB
最終ジャッジ日時 2023-10-20 15:08:22
合計ジャッジ時間 13,691 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,620 KB
testcase_01 AC 39 ms
55,620 KB
testcase_02 AC 41 ms
55,620 KB
testcase_03 AC 40 ms
55,620 KB
testcase_04 AC 187 ms
76,516 KB
testcase_05 AC 173 ms
76,308 KB
testcase_06 AC 266 ms
76,468 KB
testcase_07 AC 334 ms
76,308 KB
testcase_08 AC 199 ms
76,324 KB
testcase_09 AC 294 ms
76,532 KB
testcase_10 AC 245 ms
76,764 KB
testcase_11 AC 247 ms
76,608 KB
testcase_12 AC 352 ms
76,616 KB
testcase_13 AC 157 ms
76,684 KB
testcase_14 AC 627 ms
78,280 KB
testcase_15 AC 445 ms
77,172 KB
testcase_16 AC 733 ms
78,540 KB
testcase_17 AC 717 ms
78,244 KB
testcase_18 AC 501 ms
78,752 KB
testcase_19 AC 814 ms
78,584 KB
testcase_20 AC 507 ms
78,644 KB
testcase_21 AC 500 ms
78,644 KB
testcase_22 AC 177 ms
76,880 KB
testcase_23 AC 456 ms
78,316 KB
testcase_24 AC 236 ms
76,324 KB
testcase_25 AC 205 ms
76,468 KB
testcase_26 AC 281 ms
76,220 KB
testcase_27 AC 241 ms
76,352 KB
testcase_28 AC 205 ms
76,232 KB
testcase_29 AC 259 ms
76,732 KB
testcase_30 AC 278 ms
76,848 KB
testcase_31 AC 41 ms
55,620 KB
testcase_32 AC 43 ms
55,620 KB
testcase_33 AC 202 ms
68,768 KB
testcase_34 AC 472 ms
77,080 KB
testcase_35 AC 73 ms
74,240 KB
testcase_36 AC 134 ms
76,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V,C = map(int,input().split())

l = []
from collections import defaultdict
d = defaultdict(list)
for _ in range(N):
    v,w = map(int,input().split())
    d[v].append(w)
dp = [0] * (V + 1)
for v,l in d.items():
    nx = dp.copy()
    l.sort(reverse = True)
    while l and l[-1] + C <= l[0]:
        l.pop()
    for i in range(1,len(l)):
        l[i] += l[i-1]
    for i in range(V + 1):
        for j in range(len(l)):
            if i + (j+1) * v > V:break
            nx[i + (j+1) * v] = max(nx[i + (j+1) * v],dp[i] + C * (j + 1) + l[j])
        for j in range(len(l) + 1,(V - i) // v + 1):
            nx[i + j * v] = max(nx[i + j * v],dp[i] + C * len(l) + l[-1] + l[0] * (j - len(l)))
        
    dp = nx
print(max(dp))
0