Problem 1
In this problem we simply use the formula that is given in the problem however it may lead to floating point error.Hence we use the formula sum=sum+max(300*x,(1000-4*m[i])*x-50000*w[i])
.
Complexity : O(1)
Code : Problem A
Problem 2
In this problem,we first reverse sort the list of sizes and then allocate the k largest sizes to k blocks then we fill the leftover n-k sizes to those k blocks such that largest of n-k pairs with smallest of k boxes and second largest with second smallest and so on.
Complexity : O(nlog(n))
Code : Problem B