一维数组循环
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
https://zhuanlan.zhihu.com/p/78060568
1) input:
4 5 物品总数 不超过总重量
1 2 重量 价值
2 4
3 4
4 5
output:
8
https://en.wikipedia.org/wiki/Knapsack_problem
2) input:
10 67
23 505
26 352
20 458
18 220
32 354
27 414
29 498
26 545
30 473
27 543
output:
1270
"""
# 01背包问题 利用一维数组进行
a = raw_input()
n, m = list(map(int, a.split()))
w = [0 for i in range(n + 1)]
v = [0 for i in range(n + 1)]
for i in range(1, n + 1):
b = raw_input()
w[i], v[i] = list(map(int, b.split()))
# 定义一个数组 f[j] 表示容量为j的情况下能放的总价值最大
f = [0 for i in ran