95412024-02-22 20:25:06petergalambosSzigetek (35 pont)python3Accepted 35/35101ms34140 KiB
from sys import stdin

def main():
    N = int(input())
    D = [int(i) for i in stdin.readline().split()]
    D = [D[0]]+D
    L = [D[0]]*2+[0]*(N-1)
    
    for i in range(2,N+1):
        L[i] = D[i]+min(L[i-1],L[i-2])
    print(L[-1])
main()
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/018ms11084 KiB
2Accepted0/0100ms32196 KiB
3Accepted1/117ms11292 KiB
4Accepted1/117ms11628 KiB
5Accepted1/117ms11516 KiB
6Accepted1/117ms11856 KiB
7Accepted1/117ms12196 KiB
8Accepted2/217ms12440 KiB
9Accepted2/218ms12660 KiB
10Accepted2/218ms12684 KiB
11Accepted2/219ms13440 KiB
12Accepted2/220ms13792 KiB
13Accepted2/225ms14188 KiB
14Accepted2/232ms15680 KiB
15Accepted2/239ms18044 KiB
16Accepted2/256ms22160 KiB
17Accepted2/274ms26648 KiB
18Accepted2/281ms29160 KiB
19Accepted2/290ms31320 KiB
20Accepted2/289ms31520 KiB
21Accepted2/294ms33868 KiB
22Accepted2/2101ms34140 KiB