結果

問題 No.527 ナップサック容量問題
ユーザー 👑 rin204rin204
提出日時 2022-07-04 16:46:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 344 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 76,984 KB
最終ジャッジ日時 2023-08-21 00:30:29
合計ジャッジ時間 6,455 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,640 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 88 ms
76,608 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 111 ms
76,860 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 117 ms
76,592 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 96 ms
76,776 KB
testcase_15 AC 113 ms
76,812 KB
testcase_16 AC 87 ms
76,828 KB
testcase_17 AC 107 ms
76,708 KB
testcase_18 AC 111 ms
76,724 KB
testcase_19 AC 88 ms
76,784 KB
testcase_20 AC 102 ms
76,592 KB
testcase_21 AC 120 ms
76,580 KB
testcase_22 AC 108 ms
76,876 KB
testcase_23 AC 121 ms
76,832 KB
testcase_24 AC 92 ms
76,872 KB
testcase_25 WA -
testcase_26 AC 106 ms
76,776 KB
testcase_27 AC 108 ms
76,552 KB
testcase_28 WA -
testcase_29 AC 124 ms
76,552 KB
testcase_30 WA -
testcase_31 AC 98 ms
76,856 KB
testcase_32 AC 103 ms
76,676 KB
testcase_33 AC 100 ms
76,796 KB
testcase_34 AC 103 ms
76,776 KB
testcase_35 AC 104 ms
76,732 KB
testcase_36 WA -
testcase_37 AC 101 ms
76,732 KB
testcase_38 AC 107 ms
76,684 KB
testcase_39 AC 105 ms
76,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
W = 10 ** 5
dp = [0] * (W + 1)
for _ in range(n):
    v, w = map(int, input().split())
    for i in range(W, w - 1, -1):
        dp[i] = max(dp[i], dp[i - w] + v)
min_ = -1
max_ = -1
V = int(input())
for i in range(W + 1):
    if dp[i] == V:
        if min_ == -1:
            min_ = i
        max_ = i

print(min_)
print(max_)
0