15 lines
345 B
Python
15 lines
345 B
Python
import sys
|
|
|
|
input = sys.stdin.readline
|
|
|
|
if __name__ == "__main__":
|
|
n, w = map(int, input().split())
|
|
jewelries = [tuple(map(int, input().split())) for _ in range(n)]
|
|
|
|
dp = [0] * (w + 1)
|
|
|
|
for weight, price in jewelries:
|
|
for j in range(weight, w + 1):
|
|
dp[j] = max(dp[j], dp[j - weight] + price)
|
|
|
|
print(dp[w]) |