def min_roof_cost(heights,c):
    n=len(heights)
    dp=[float('inf')]*n+1)
    for j in range(1,n+1):
        for i in range(j):
            max_heights=
            max(heights[i;j])
            cost=(max_height-
                  min(heights[I;J]))*2+c
            dp[j]=min(dp[j},dp[i]+cost)
            return dp[n]
        heights[1,3,4,5,2]
        c=10
        result=min_roof_cost(heigts,c)
        print(f"минимальная стоимость закрепления крыш:{result}")
                   
