Company: Microsoft_5march
Difficulty: medium
A shopkeeper arranges items in a list for a sale. Starting from the left, each item is sold at its full price minus the price of the first item to its right that is of equal or lower price. If no such item exists, the current item is sold at its full price. Print the sum of the final cost for all items, then on the next line, print space-separated, 0-based indices of items that are sold at full price, in ascending order. For example, consider the item prices [2, 3, 1, 2, 4, 2]. Items at indices 0 and 1 are each discounted by 1 unit, the first equal or lower price to their right. Item 2, priced at 1 unit, sells at full price as there are no equal or lower-priced items to its right. Item 3, priced at 2 units, is discounted by 2 units to 0. Item 4, priced at 4 units, is discounted by 2 units to 2. The final item, priced at 2 units, is sold at full price as there are no items to its right. The total cost amounts to 1 + 2 + 1 + 0 + 2 + 2 = 8 units, with full price items at indices [2, 5] us