結果

問題 No.527 ナップサック容量問題
ユーザー titiatitia
提出日時 2024-02-02 04:57:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 62,516 KB
最終ジャッジ日時 2024-02-02 04:57:08
合計ジャッジ時間 5,086 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
60,256 KB
testcase_01 AC 49 ms
60,256 KB
testcase_02 AC 46 ms
60,384 KB
testcase_03 AC 51 ms
62,512 KB
testcase_04 AC 70 ms
60,288 KB
testcase_05 AC 72 ms
62,512 KB
testcase_06 AC 97 ms
62,508 KB
testcase_07 AC 86 ms
62,512 KB
testcase_08 AC 67 ms
62,512 KB
testcase_09 AC 42 ms
60,288 KB
testcase_10 AC 94 ms
62,508 KB
testcase_11 AC 80 ms
62,508 KB
testcase_12 AC 73 ms
62,512 KB
testcase_13 AC 98 ms
62,508 KB
testcase_14 AC 64 ms
62,508 KB
testcase_15 AC 75 ms
62,512 KB
testcase_16 AC 48 ms
62,516 KB
testcase_17 AC 73 ms
62,516 KB
testcase_18 AC 75 ms
62,512 KB
testcase_19 AC 50 ms
62,516 KB
testcase_20 AC 64 ms
62,512 KB
testcase_21 AC 102 ms
62,508 KB
testcase_22 AC 83 ms
62,508 KB
testcase_23 AC 101 ms
62,508 KB
testcase_24 AC 57 ms
62,516 KB
testcase_25 AC 82 ms
62,508 KB
testcase_26 AC 78 ms
62,512 KB
testcase_27 AC 78 ms
62,512 KB
testcase_28 AC 74 ms
62,512 KB
testcase_29 AC 99 ms
62,508 KB
testcase_30 AC 49 ms
60,384 KB
testcase_31 AC 69 ms
62,508 KB
testcase_32 AC 73 ms
62,508 KB
testcase_33 AC 70 ms
62,508 KB
testcase_34 AC 76 ms
62,508 KB
testcase_35 AC 79 ms
62,512 KB
testcase_36 AC 48 ms
62,516 KB
testcase_37 AC 70 ms
62,516 KB
testcase_38 AC 76 ms
62,512 KB
testcase_39 AC 74 ms
62,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
V=int(input())

DP=[0]*100002

for v,w in L:
    for i in range(100001,-1,-1):
        if i+w<100002:
            DP[i+w]=max(DP[i+w],DP[i]+v)

flag=0
for i in range(1,100002):
    if flag==0 and DP[i]==V:
        print(i)
        flag=1
    if flag==1:
        if DP[i]!=V:
            print(i-1)
            break
else:
    print("inf")
    
0