''' mbinary ######################################################################### # File : splitStripe.py # Author: mbinary # Mail: zhuheqin1@gmail.com # Blog: https://mbinary.xyz # Github: https://github.com/mbinary # Created Time: 2018-08-24 17:07 # Description: ######################################################################### ''' ''' There is stripe which length is n, priceMap contains a map for different length of stripe and its price then find the maximum price to split the stripe in different shorter stripes ( including the original length if possible) ''' def count(n,prices): def best(cur): # note that copying the list or create a new list in the following new_stripes codes if cur in values: return values[cur],stripes[cur] maxPrice = 0 new_stripes=[] for i,j in prices.items(): if i<=cur: p, tmp = best(cur-i) if maxPrice