結果

問題 No.527 ナップサック容量問題
ユーザー pluto77pluto77
提出日時 2017-06-16 09:03:19
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 348 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 77,044 KB
実行使用メモリ 158,324 KB
最終ジャッジ日時 2024-04-08 13:22:17
合計ジャッジ時間 9,547 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
81,524 KB
testcase_01 AC 100 ms
82,420 KB
testcase_02 AC 93 ms
80,884 KB
testcase_03 AC 98 ms
82,420 KB
testcase_04 AC 88 ms
79,988 KB
testcase_05 AC 194 ms
111,092 KB
testcase_06 AC 310 ms
146,548 KB
testcase_07 AC 263 ms
132,980 KB
testcase_08 AC 176 ms
106,228 KB
testcase_09 AC 88 ms
80,116 KB
testcase_10 AC 313 ms
147,188 KB
testcase_11 AC 243 ms
126,836 KB
testcase_12 AC 200 ms
113,396 KB
testcase_13 AC 316 ms
148,980 KB
testcase_14 AC 171 ms
103,796 KB
testcase_15 AC 219 ms
118,772 KB
testcase_16 AC 98 ms
82,420 KB
testcase_17 AC 195 ms
111,732 KB
testcase_18 AC 211 ms
116,468 KB
testcase_19 AC 104 ms
83,316 KB
testcase_20 AC 177 ms
105,332 KB
testcase_21 AC 348 ms
158,324 KB
testcase_22 AC 265 ms
131,444 KB
testcase_23 AC 344 ms
155,892 KB
testcase_24 AC 144 ms
94,196 KB
testcase_25 AC 254 ms
129,908 KB
testcase_26 AC 236 ms
124,404 KB
testcase_27 AC 240 ms
125,172 KB
testcase_28 AC 219 ms
118,772 KB
testcase_29 AC 342 ms
157,556 KB
testcase_30 AC 109 ms
86,388 KB
testcase_31 AC 197 ms
112,500 KB
testcase_32 AC 220 ms
120,436 KB
testcase_33 AC 200 ms
114,036 KB
testcase_34 AC 225 ms
121,972 KB
testcase_35 AC 229 ms
121,972 KB
testcase_36 AC 95 ms
81,524 KB
testcase_37 AC 192 ms
110,964 KB
testcase_38 AC 220 ms
119,540 KB
testcase_39 AC 209 ms
116,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_527

n=int(raw_input())
v=[]
w=[]
for i in xrange(n):
 v1,w1=map(int,raw_input().split())
 v.append(v1)
 w.append(w1)
V=int(raw_input())
dp=[[0 for i in xrange(101010)] for j in xrange(n+1)]
for i in xrange(n):
 for j in xrange(100002):
  dp[i+1][j]=max(dp[i+1][j],dp[i][j])
  dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i])
mn=float('inf')
mx=-1
for i in xrange(1,100002):
 if dp[n][i]==V:
  mn=min(mn,i)
  mx=max(mx,i)
print mn
if mx==100001:
 print 'inf'
else:
 print mx
0