Company: Agoda_16nov
Difficulty: medium
Product Sales Problem Description A product marketer works with multiple suppliers, each with different stock levels represented by an array. When an item is purchased from a supplier, that supplier increases the price by 1 unit per item, reducing the marketer's profit. The profit on any item equals the number of those items the supplier has remaining. For example, with 4 units in stock, the profit sequence is: 4, 3, 2, and 1. Given an array of quantities for each supplier and the number of items ordered, determine the maximum possible profit. Example 1: Input: inventory = [2, 5], order = 6 Output: 19 Explanation: Two suppliers have inventory = [2, 5] units to sell, and 6 items were ordered. The maximum profit is made by selling 1 unit for 5, 1 for 4, and 2 at 3 and 2 units profit. The two items are left with a unit of product each. The maximum profit generated is 5 + 4 + 2 * 3 + 2 * 2 = 19. Maximizing profit: Green represents units purchased by the marketer, red squares are products r