Can anybody please tell how do you handle this kind of questions. I can't seem to find a solution.
Fofo, the richest man in the city has a big problem and he believes that you are the only one capable of solving it. He has recently completed N projects and earned A[i] profit for every project. He now wants to build M warehouses such that each warehouse can accommodate K bundles of money. The money bundles must be distributed such that the following conditions are true: • The profit earned from a project is not distributed among more than one warehouse. • The warehouse can contain more than one project's profit, provided that the total number of bundles does not exceed K. Now he wants your help by determining the smallest value for K so that he can place all the bundles in the M warehouses. Find the smallest possible value of K such that the profit earned from all projects is distributed across the M warehouses.