Given an array A of N numbers, you have to perform B operations. In each operation, you have to pick any one of the N elements and add original value(value stored at index before we did any operations) to it's current value. You can choose any of the N elements in each operation.
Perform B operations in such a way that the largest element of the modified array(after B operations) is minimised. Return an integer corresponding to the minimum possible largest element after K operations.
Example:
Input : A = [1, 2, 3, 4] B = 3
Output : 4
Explanation : After the 1st operation the array would change to [2, 2, 3, 4] After the 2nd operation the array would change to [3, 2, 3, 4] After the 3rd operation the array would change to [4, 2, 3, 4]
A : [ 8, 6, 4, 2 ] B : 8 The expected returned value : 12
Thanks : the problem is sold, one more way to solve this problem is to use min heap priority queue with the following comparator
struct op
{
bool operator()(const pll &a , const pll &b)
{
return a.fi + a.se > b.fi + b.se;
}
};