Given an array arr[] of size N where every index in the array represents the cost of buying an item and two numbers P, K. The task is to find the maximum number of items which can be bought such that:
1. If some i-th object is bought from the array, the remaining amount becomes P – arr{i}
2. We can buy K items, not necessarily consecutive, at a time by paying only for the item whose cost is maximum among them. Now, the remaining amount would be P – max(cost of K items).