Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def find_cur_profits(size, length, salePrice, costPerCut):
- totalUniformRods = length//size
- cuts = totalUniformRods -1 if length % size == 0 else totalUniformRods #number of cuts during process;
- currentProfits = totalUniformRods * salePrice * size - costPerCut * cuts;
- return currentProfits
- def sol(costPerCut, salePrice, lengths):
- maxProfit = 0
- for size in range(1,max(lengths)+1):
- profits = 0
- for i in range(len(lengths)):
- if(size > lengths[i]):
- continue;
- currentProfits = find_cur_profits(size, lengths[i], salePrice, costPerCut)
- if(currentProfits > 0):
- profits += currentProfits;
- if(profits > maxProfit):
- maxProfit = profits
- return maxProfit
- sol(1,10,[30,59,110]) #1913
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement