結果

問題 No.527 ナップサック容量問題
ユーザー H3PO4H3PO4
提出日時 2020-09-14 09:50:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 380 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 31,992 KB
最終ジャッジ日時 2023-09-04 00:35:34
合計ジャッジ時間 8,509 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
31,796 KB
testcase_01 AC 130 ms
31,992 KB
testcase_02 AC 128 ms
31,796 KB
testcase_03 AC 129 ms
31,808 KB
testcase_04 AC 127 ms
30,940 KB
testcase_05 AC 165 ms
31,740 KB
testcase_06 AC 202 ms
31,980 KB
testcase_07 AC 186 ms
31,884 KB
testcase_08 AC 157 ms
31,888 KB
testcase_09 AC 129 ms
31,040 KB
testcase_10 AC 205 ms
31,768 KB
testcase_11 AC 180 ms
31,744 KB
testcase_12 AC 164 ms
31,900 KB
testcase_13 AC 205 ms
31,688 KB
testcase_14 AC 159 ms
31,800 KB
testcase_15 AC 171 ms
31,892 KB
testcase_16 AC 129 ms
31,892 KB
testcase_17 AC 166 ms
31,876 KB
testcase_18 AC 170 ms
31,820 KB
testcase_19 AC 130 ms
31,964 KB
testcase_20 AC 156 ms
31,788 KB
testcase_21 AC 214 ms
31,696 KB
testcase_22 AC 184 ms
31,700 KB
testcase_23 AC 213 ms
31,916 KB
testcase_24 AC 146 ms
31,860 KB
testcase_25 AC 185 ms
31,944 KB
testcase_26 AC 180 ms
31,796 KB
testcase_27 AC 182 ms
31,784 KB
testcase_28 AC 174 ms
31,812 KB
testcase_29 AC 219 ms
31,924 KB
testcase_30 AC 138 ms
31,708 KB
testcase_31 AC 168 ms
31,820 KB
testcase_32 AC 176 ms
31,844 KB
testcase_33 AC 168 ms
31,856 KB
testcase_34 AC 177 ms
31,956 KB
testcase_35 AC 175 ms
31,828 KB
testcase_36 AC 129 ms
31,948 KB
testcase_37 AC 162 ms
31,924 KB
testcase_38 AC 172 ms
31,784 KB
testcase_39 AC 172 ms
31,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N = int(input())

MAX = 100000
dp = np.zeros(MAX + 1, dtype=int)
ans_min = MAX + 1
ans_max = 0
for _ in range(N):
    v, w = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
V = int(input())

l = np.searchsorted(dp, V, side='left')
r = np.searchsorted(dp, V, side='right')
print(l if l > 0 else 1)
print('inf' if r - 1 == MAX else r - 1)
0