complete at jungol 1077.py 3135.py 14020.py 3006.rs

This commit is contained in:
2026-07-29 22:28:56 +09:00
parent 8f06210897
commit 6a4ee13ce2
4 changed files with 95 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
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])