結果

問題 No.527 ナップサック容量問題
ユーザー convexineqconvexineq
提出日時 2021-02-24 01:18:37
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 253 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 63,252 KB
最終ジャッジ日時 2023-10-24 03:30:47
合計ジャッジ時間 3,943 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
61,044 KB
testcase_01 AC 46 ms
61,044 KB
testcase_02 AC 44 ms
60,260 KB
testcase_03 AC 49 ms
63,248 KB
testcase_04 AC 44 ms
61,028 KB
testcase_05 AC 68 ms
60,404 KB
testcase_06 AC 78 ms
62,452 KB
testcase_07 AC 71 ms
63,236 KB
testcase_08 AC 57 ms
60,404 KB
testcase_09 AC 41 ms
60,244 KB
testcase_10 AC 77 ms
63,236 KB
testcase_11 AC 65 ms
60,404 KB
testcase_12 AC 61 ms
60,404 KB
testcase_13 AC 79 ms
62,452 KB
testcase_14 AC 56 ms
61,188 KB
testcase_15 AC 72 ms
61,188 KB
testcase_16 AC 47 ms
61,052 KB
testcase_17 AC 68 ms
61,188 KB
testcase_18 AC 71 ms
61,188 KB
testcase_19 AC 47 ms
61,188 KB
testcase_20 AC 63 ms
61,188 KB
testcase_21 AC 83 ms
63,236 KB
testcase_22 AC 70 ms
63,236 KB
testcase_23 AC 81 ms
63,236 KB
testcase_24 AC 52 ms
61,188 KB
testcase_25 AC 81 ms
63,236 KB
testcase_26 AC 66 ms
61,188 KB
testcase_27 AC 67 ms
61,188 KB
testcase_28 AC 64 ms
61,188 KB
testcase_29 AC 83 ms
63,236 KB
testcase_30 AC 47 ms
60,260 KB
testcase_31 AC 61 ms
61,188 KB
testcase_32 AC 63 ms
61,188 KB
testcase_33 AC 60 ms
61,188 KB
testcase_34 AC 63 ms
61,188 KB
testcase_35 AC 65 ms
61,188 KB
testcase_36 AC 46 ms
61,052 KB
testcase_37 AC 61 ms
63,252 KB
testcase_38 AC 63 ms
61,188 KB
testcase_39 AC 62 ms
61,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
N = 10**5+1
dp = [0]*N
for _ in range(n):
    v,w = map(int,input().split())
    for i in range(w,N)[::-1]: dp[i] = max(dp[i],dp[i-w]+v)
V = int(input())
print(max(1,dp.index(V)))
print("inf" if dp[-1]==V else N - dp[::-1].index(V) - 1)
0