(P) Разрежь ленточку

public
yeskendir.sultanov Apr 26, 2024 Never 59
Clone
Python 48.py 22 lines (17 loc) | 543 Bytes
1
n, a, b, c = map(int, input().split())
2
3
dp = [False for i in range(n + 1)]
4
dc = [0 for i in range(n + 1)]
5
6
dp[0] = True
7
dc[0] = 0
8
9
for x in range(n + 1):
10
if dp[x] == True:
11
if x + a <= n:
12
dp[x + a] = True
13
dc[x + a] = max(dc[x + a], dc[x] + 1)
14
if x + b <= n:
15
dp[x + b] = True
16
dc[x + b] = max(dc[x + b], dc[x] + 1)
17
if x + c <= n:
18
dp[x + c] = True
19
dc[x + c] = max(dc[x + c], dc[x] + 1)
20
21
22
print(dc[n])