Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://inf-ege.sdamgia.ru/problem?id=27423
- data = open('26_demo.txt').readlines()
- s, n = map(int, data[0].split())
- a = list(map(int, data[1:]))
- dp = [0] * (s + 1)
- for e in a:
- nw = dp.copy()
- for i in range(s):
- if dp[i] != 0 and i + e <= s:
- nw[i + e] = max(nw[i + e], dp[i] + 1)
- nw[e] = max(nw[e], 1)
- dp = nw.copy()
- print(max(dp))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement