結果
問題 | No.527 ナップサック容量問題 |
ユーザー | nanae |
提出日時 | 2017-06-09 22:36:35 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 738 bytes |
コンパイル時間 | 1,088 ms |
コンパイル使用メモリ | 11,900 KB |
実行使用メモリ | 18,368 KB |
最終ジャッジ日時 | 2023-10-23 22:06:04 |
合計ジャッジ時間 | 27,370 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 116 ms
10,780 KB |
testcase_01 | AC | 149 ms
13,948 KB |
testcase_02 | AC | 87 ms
10,780 KB |
testcase_03 | AC | 154 ms
13,948 KB |
testcase_04 | AC | 60 ms
10,780 KB |
testcase_05 | AC | 1,221 ms
13,948 KB |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | AC | 1,042 ms
13,948 KB |
testcase_09 | AC | 57 ms
10,780 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 1,819 ms
13,948 KB |
testcase_12 | AC | 1,312 ms
13,948 KB |
testcase_13 | TLE | - |
testcase_14 | AC | 955 ms
13,948 KB |
testcase_15 | AC | 1,519 ms
13,948 KB |
testcase_16 | AC | 164 ms
13,948 KB |
testcase_17 | AC | 1,253 ms
13,948 KB |
testcase_18 | AC | 1,440 ms
13,948 KB |
testcase_19 | AC | 183 ms
13,948 KB |
testcase_20 | AC | 1,022 ms
13,948 KB |
testcase_21 | TLE | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
ソースコード
import sys lim = 10**5 def solve(): n = int(input()) v = [0] * n w = [0] * n for i in range(n): vi, wi = map(int, input().split()) v[i] = vi w[i] = wi V = int(input()) dp = [0] * (lim + 1) for i in range(n): for j in range(lim, w[i] - 1, -1): dp[j] = max(dp[j], dp[j - w[i]] + v[i]) min_a = lim + 1 max_a = 0 for i in range(lim + 1): if dp[i] == V: min_a = i break for i in range(lim, -1, -1): if dp[i] == V: max_a = i break print(min_a if min_a > 0 else 1) if sum(v) == V: print('inf') else: print(max_a) if __name__ == '__main__': solve()