Mr. Octopus has recently shut down hisfactory and want to sell off his metal rods to a local businessman.
In order to maximize profit, he should sellthe metal of same size and shape. If he sells metal rods of length ,he receives N x L xmetal_price. The remaining smallermetal rods will be thrown away. To cut the metal rods, he needs to pay cost_per_cut for every cut.
What is the maximum amount of money Mr.Octopus can make?
First line of input contains cost_per_cut
Second line of input contains metal_price
Third line contains L, the number of rods Mr. Octopus has,followed by L integers in each line representinglength of each rod.
Print the result corresponding to the testcase.
1 <= metal_price, cost_per_cut <= 1000
1 <= L <= 50
Each element of lenghts will lie in range [1, 10000].
Here cuts are pretty cheap. So we can make largenumber of cuts to reduce the amount of wood wasted. Most opt
imal lengths ofrods will be . So we will cut pieces of length from rod,and throw peice of length from it. Similarly we will cut piecesof length from rod and throw away a piece of length .From rod, we will cut pieces of length andthrow a piece of length . So in total we have pieces of length andwe have made cuts also. So total profit is
. more info on 1point3acres.com
补充内容 (2016-10-4 07:42):