88272024-01-31 17:27:55NagyLeoSzigetek (35 pont)python3Elfogadva 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())


RészfeladatÖsszpontTesztVerdiktIdőMemória
base35/35
1Elfogadva0/018ms10996 KiB
2Elfogadva0/075ms32460 KiB
3Elfogadva1/117ms11940 KiB
4Elfogadva1/117ms11872 KiB
5Elfogadva1/117ms12240 KiB
6Elfogadva1/117ms11896 KiB
7Elfogadva1/117ms12128 KiB
8Elfogadva2/218ms12240 KiB
9Elfogadva2/218ms12820 KiB
10Elfogadva2/218ms12824 KiB
11Elfogadva2/220ms13276 KiB
12Elfogadva2/220ms13944 KiB
13Elfogadva2/223ms14364 KiB
14Elfogadva2/229ms16532 KiB
15Elfogadva2/235ms18992 KiB
16Elfogadva2/248ms23864 KiB
17Elfogadva2/257ms28168 KiB
18Elfogadva2/265ms30568 KiB
19Elfogadva2/274ms32524 KiB
20Elfogadva2/268ms32464 KiB
21Elfogadva2/274ms34212 KiB
22Elfogadva2/275ms34596 KiB