159692025-03-26 08:49:02lacitoSzigetek (35 pont)pypy3Accepted 35/3579ms31860 KiB
n = int(input())
cost = [int(x) for x in input().split()]
dp = [0] * n
dp[0] = cost[0]
dp[1] = cost[0] + cost[1]
for i in range(2, n):
    dp[i] = min(dp[i - 1], dp[i - 2]) + cost[i]
print(dp[n - 1])

"""
6
3 5 9 7 1 6
"""
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/041ms19336 KiB
2Accepted0/079ms31860 KiB
3Accepted1/139ms19392 KiB
4Accepted1/143ms19360 KiB
5Accepted1/141ms19436 KiB
6Accepted1/139ms19328 KiB
7Accepted1/146ms19456 KiB
8Accepted2/245ms21072 KiB
9Accepted2/250ms21616 KiB
10Accepted2/257ms21660 KiB
11Accepted2/257ms21640 KiB
12Accepted2/250ms21604 KiB
13Accepted2/250ms21640 KiB
14Accepted2/259ms22392 KiB
15Accepted2/261ms23232 KiB
16Accepted2/257ms25572 KiB
17Accepted2/271ms28648 KiB
18Accepted2/263ms29416 KiB
19Accepted2/274ms30440 KiB
20Accepted2/265ms30704 KiB
21Accepted2/275ms31720 KiB
22Accepted2/265ms31820 KiB