結果

問題 No.527 ナップサック容量問題
ユーザー 👑 rin204rin204
提出日時 2022-07-04 16:47:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 86,660 KB
実行使用メモリ 76,924 KB
最終ジャッジ日時 2023-08-21 00:31:19
合計ジャッジ時間 5,713 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
76,744 KB
testcase_01 AC 79 ms
76,800 KB
testcase_02 AC 80 ms
76,804 KB
testcase_03 AC 84 ms
76,752 KB
testcase_04 AC 78 ms
76,436 KB
testcase_05 AC 104 ms
76,924 KB
testcase_06 AC 114 ms
76,800 KB
testcase_07 AC 108 ms
76,608 KB
testcase_08 AC 93 ms
76,800 KB
testcase_09 AC 76 ms
76,816 KB
testcase_10 AC 114 ms
76,472 KB
testcase_11 AC 103 ms
76,716 KB
testcase_12 AC 95 ms
76,732 KB
testcase_13 AC 113 ms
76,828 KB
testcase_14 AC 94 ms
76,724 KB
testcase_15 AC 109 ms
76,924 KB
testcase_16 AC 81 ms
76,764 KB
testcase_17 AC 103 ms
76,828 KB
testcase_18 AC 106 ms
76,700 KB
testcase_19 AC 83 ms
76,852 KB
testcase_20 AC 98 ms
76,728 KB
testcase_21 AC 118 ms
76,792 KB
testcase_22 AC 106 ms
76,908 KB
testcase_23 AC 117 ms
76,788 KB
testcase_24 AC 88 ms
76,708 KB
testcase_25 AC 116 ms
76,640 KB
testcase_26 AC 101 ms
76,700 KB
testcase_27 AC 102 ms
76,584 KB
testcase_28 AC 100 ms
76,588 KB
testcase_29 AC 119 ms
76,584 KB
testcase_30 AC 82 ms
76,868 KB
testcase_31 AC 96 ms
76,784 KB
testcase_32 AC 99 ms
76,772 KB
testcase_33 AC 98 ms
76,864 KB
testcase_34 AC 99 ms
76,728 KB
testcase_35 AC 100 ms
76,828 KB
testcase_36 AC 80 ms
76,812 KB
testcase_37 AC 96 ms
76,624 KB
testcase_38 AC 99 ms
76,708 KB
testcase_39 AC 97 ms
76,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
W = 10 ** 5 + 10
dp = [0] * (W + 1)
for _ in range(n):
    v, w = map(int, input().split())
    for i in range(W, w - 1, -1):
        dp[i] = max(dp[i], dp[i - w] + v)
min_ = -1
max_ = -1
V = int(input())
for i in range(1, W + 1):
    if dp[i] == V:
        if min_ == -1:
            min_ = i
        max_ = i

print(min_)
if max_ == W:
    max_ = "inf"
print(max_)
0