結果

問題 No.527 ナップサック容量問題
ユーザー h_nosonh_noson
提出日時 2017-06-09 22:49:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 463 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 12,936 KB
最終ジャッジ日時 2023-10-23 22:20:28
合計ジャッジ時間 24,314 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
11,560 KB
testcase_01 AC 132 ms
11,560 KB
testcase_02 AC 138 ms
11,560 KB
testcase_03 AC 136 ms
11,560 KB
testcase_04 AC 131 ms
11,560 KB
testcase_05 AC 696 ms
12,088 KB
testcase_06 TLE -
testcase_07 AC 925 ms
12,088 KB
testcase_08 AC 520 ms
12,088 KB
testcase_09 AC 132 ms
11,560 KB
testcase_10 TLE -
testcase_11 AC 1,211 ms
12,352 KB
testcase_12 AC 756 ms
12,352 KB
testcase_13 TLE -
testcase_14 AC 377 ms
12,088 KB
testcase_15 AC 652 ms
12,088 KB
testcase_16 AC 131 ms
11,560 KB
testcase_17 AC 653 ms
12,088 KB
testcase_18 AC 869 ms
12,352 KB
testcase_19 AC 137 ms
11,560 KB
testcase_20 AC 210 ms
11,824 KB
testcase_21 AC 576 ms
11,824 KB
testcase_22 AC 323 ms
11,824 KB
testcase_23 AC 407 ms
11,824 KB
testcase_24 AC 174 ms
11,560 KB
testcase_25 AC 129 ms
11,560 KB
testcase_26 AC 193 ms
11,560 KB
testcase_27 AC 156 ms
11,560 KB
testcase_28 AC 131 ms
11,560 KB
testcase_29 AC 234 ms
11,560 KB
testcase_30 AC 147 ms
11,560 KB
testcase_31 AC 568 ms
11,560 KB
testcase_32 AC 1,089 ms
11,560 KB
testcase_33 AC 726 ms
11,560 KB
testcase_34 AC 670 ms
11,560 KB
testcase_35 AC 138 ms
11,560 KB
testcase_36 AC 131 ms
11,560 KB
testcase_37 AC 137 ms
11,560 KB
testcase_38 AC 136 ms
11,560 KB
testcase_39 AC 136 ms
11,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 9

N = int(input())
mx = 0
mn = INF
v = []
w = []
for i in range(N):
    x, y = map(int,input().split(' '))
    v.append(x)
    w.append(y)
V = int(input())
dp = [0] * (200000)
for i in range(1,200000):
    dp[i] = INF
for i in range(N):
    for j in range(V+1)[::-1]:
        dp[j+v[i]] = min(dp[j+v[i]],dp[j] + w[i])
print(max(1,dp[V]))
mx = INF
for i in range(V+1,200000):
    mx = min(mx,dp[i])
if mx == INF:
    print("inf")
else:
    print(mx-1)
0