結果

問題 No.1947 質より種類数
ユーザー terasaterasa
提出日時 2022-05-22 11:06:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 758 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 78,940 KB
最終ジャッジ日時 2023-10-20 16:55:18
合計ジャッジ時間 6,569 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
66,324 KB
testcase_01 AC 60 ms
66,324 KB
testcase_02 AC 61 ms
66,324 KB
testcase_03 AC 63 ms
66,324 KB
testcase_04 AC 75 ms
73,584 KB
testcase_05 AC 75 ms
73,584 KB
testcase_06 AC 77 ms
73,596 KB
testcase_07 AC 76 ms
73,584 KB
testcase_08 AC 75 ms
73,584 KB
testcase_09 AC 79 ms
73,584 KB
testcase_10 AC 77 ms
73,584 KB
testcase_11 AC 89 ms
73,796 KB
testcase_12 AC 82 ms
73,576 KB
testcase_13 AC 77 ms
73,584 KB
testcase_14 AC 165 ms
78,496 KB
testcase_15 AC 120 ms
75,372 KB
testcase_16 AC 207 ms
78,468 KB
testcase_17 AC 237 ms
78,612 KB
testcase_18 AC 356 ms
78,844 KB
testcase_19 AC 320 ms
78,792 KB
testcase_20 AC 263 ms
78,824 KB
testcase_21 AC 295 ms
78,756 KB
testcase_22 AC 89 ms
73,812 KB
testcase_23 AC 179 ms
78,420 KB
testcase_24 AC 75 ms
73,584 KB
testcase_25 AC 73 ms
73,564 KB
testcase_26 AC 71 ms
71,508 KB
testcase_27 AC 72 ms
71,516 KB
testcase_28 AC 74 ms
73,584 KB
testcase_29 AC 325 ms
78,936 KB
testcase_30 AC 350 ms
78,932 KB
testcase_31 AC 60 ms
66,324 KB
testcase_32 AC 59 ms
66,324 KB
testcase_33 AC 69 ms
71,504 KB
testcase_34 AC 130 ms
78,840 KB
testcase_35 AC 118 ms
78,756 KB
testcase_36 AC 356 ms
78,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict, Counter
import string
import random

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


N, Pmax, C = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(N)]

dp = [0 for _ in range(Pmax + 1)]
for i in range(N):
    price, value = P[i]
    value += C
    for j in range(Pmax + 1)[::-1]:
        if j - price < 0:
            break
        dp[j] = max(dp[j], dp[j - price] + value)
for i in range(N):
    price, value = P[i]
    for j in range(Pmax + 1):
        if j - price < 0:
            continue
        dp[j] = max(dp[j], dp[j - price] + value)
print(max(dp))
0