Three girls are shopping at a supermarket. The supermarket is having a sale: "Spend $50 or more in a single transaction and get $10 off." The girls realize that if they combine their purchases, they might be able to pay less than if they each pay separately. For example, if they are buying a total of $46, $62 and $9 worth of goods, respectively, they can combine the $46 and $9 totals and make two purchase transactions ($55 and $62) to get $20 off.
You will be given a int[] goods, each element of which is the total cost of the goods purchased by one of the girls. Return the minimal total cost required to purchase all the goods. The girls are willing to combine their purchases as described above, but no girl is willing to split up her goods across multiple transactions. |