結果

問題 No.527 ナップサック容量問題
ユーザー hedwig100hedwig100
提出日時 2020-05-26 18:24:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 397 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,720 KB
最終ジャッジ日時 2024-04-21 04:25:04
合計ジャッジ時間 22,076 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 479 ms
44,328 KB
testcase_01 AC 484 ms
43,820 KB
testcase_02 AC 481 ms
43,944 KB
testcase_03 WA -
testcase_04 AC 481 ms
44,200 KB
testcase_05 AC 496 ms
43,948 KB
testcase_06 AC 496 ms
44,084 KB
testcase_07 WA -
testcase_08 AC 495 ms
44,072 KB
testcase_09 AC 492 ms
43,952 KB
testcase_10 WA -
testcase_11 AC 526 ms
44,468 KB
testcase_12 AC 505 ms
44,200 KB
testcase_13 AC 494 ms
43,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 493 ms
43,812 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 485 ms
44,200 KB
testcase_29 WA -
testcase_30 AC 489 ms
44,072 KB
testcase_31 AC 485 ms
44,072 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 491 ms
44,332 KB
testcase_36 AC 482 ms
44,336 KB
testcase_37 AC 490 ms
44,200 KB
testcase_38 AC 501 ms
44,076 KB
testcase_39 AC 489 ms
44,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
INF = 10 ** 10

N = int(input())
item = [tuple(map(int,input().split())) for _ in range(N)]
V = int(input())

dp = np.zeros(V + 2,np.int64)
dp[1:] = INF
for v,w in item:
    dp[v:] = np.minimum(dp[v:],dp[:-v] + w)

if dp[-2] == 0:
    ans = 1,min(w for v,w in item) - 1
elif dp[-1] == INF:
    ans = dp[-2],'inf'
else:
    ans = dp[-2],dp[-1] - 1
print('\n'.join(map(str,ans))) 
0