<doocs>1105.Filling Bookcase Shelves_1.py
def minHeightShelves( books: List[List[int]], shelfWidth: int) -> int:
    n = len(books)
    dp = [0] * (n + 1)
    dp[1] = books[0][1]
    for i in range(2, n + 1):
        dp[i] = books[i - 1][1] + dp[i - 1]
        w, h = books[i - 1][0], books[i - 1][1]
        for j in range(i - 1, 0, -1):
            w += books[j - 1][0]
            if w > shelfWidth:
                break
            h = max(books[j - 1][1], h)
            dp[i] = min(dp[i], dp[j - 1] + h)
    return dp[n]
def sample_funcname ( var_0 : List [ List [ int ] ] , var_3 : int ) -> int :
    var_5 = len ( var_0 )
    var_8 = [ 0 ] * ( var_5 + 1 )
    var_8 [ 1 ] = var_0 [ 0 ] [ 1 ]
    for var_11 in range ( 2 , var_5 + 1 ) :
        var_8 [ var_11 ] = var_0 [ var_11 - 1 ] [ 1 ] + var_8 [ var_11 - 1 ]
        var_12 , var_13 = var_0 [ var_11 - 1 ] [ 0 ] , var_0 [ var_11 - 1 ] [ 1 ]
        for var_14 in range ( var_11 - 1 , 0 , - 1 ) :
            var_12 += var_0 [ var_14 - 1 ] [ 0 ]
            if var_12 > var_3 :
                break
            var_13 = max ( var_0 [ var_14 - 1 ] [ 1 ] , var_13 )
            var_8 [ var_11 ] = min ( var_8 [ var_11 ] , var_8 [ var_14 - 1 ] + var_13 )
    return var_8 [ var_5 ]
