88272024-01-31 17:27:55NagyLeoSzigetek (35 pont)python3Accepted 35/3575ms34596 KiB
def min_cost():
    N = int(input())
    fees = list(map(int, input().split()))
    min_fees = [0] * N

    min_fees[0] = fees[0]
    min_fees[1] = fees[0] + fees[1]
    for i in range(2, N):
        min_fees[i] = min(min_fees[i - 1], min_fees[i - 2]) + fees[i]

    return min_fees[N - 1]


def min_cost2():
    N = int(input())
    fees = list(map(int, input().split()))

    a, b = fees[0], fees[0] + fees[1]
    for i in range(2, N):
        a, b = b, min(a, b) + fees[i]

    return b


print(min_cost2())


SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/018ms10996 KiB
2Accepted0/075ms32460 KiB
3Accepted1/117ms11940 KiB
4Accepted1/117ms11872 KiB
5Accepted1/117ms12240 KiB
6Accepted1/117ms11896 KiB
7Accepted1/117ms12128 KiB
8Accepted2/218ms12240 KiB
9Accepted2/218ms12820 KiB
10Accepted2/218ms12824 KiB
11Accepted2/220ms13276 KiB
12Accepted2/220ms13944 KiB
13Accepted2/223ms14364 KiB
14Accepted2/229ms16532 KiB
15Accepted2/235ms18992 KiB
16Accepted2/248ms23864 KiB
17Accepted2/257ms28168 KiB
18Accepted2/265ms30568 KiB
19Accepted2/274ms32524 KiB
20Accepted2/268ms32464 KiB
21Accepted2/274ms34212 KiB
22Accepted2/275ms34596 KiB