There is a sale going on in Chefland. For every
items Chef pays for, he gets the third item for free (see sample explanations for more clarity).
It is given that the cost of
item is rupees. Find the minimum money required by Chef to buy at leastitems.
Input Format
- First line will contain
- .
Output Format
For each test case, output the minimum money required by Chef to buy at least
items.
Constraints
Subtasks
- Subtask 1 (100 points): Original constraints.
Sample Input 1
4
3 4
4 2
5 3
6 1
Sample Output 1
8
6
12
4
Explanation
Test Case
: Chef wants items where the cost of each item is rupees. To minimise the expenditure, Chef can pay for items and get the third item for free. This way, the total money required isrupees.
Test Case
: To minimise the expenditure, Chef can do the following:
- Purchase
- items.
Thus, the minimum money required to buy
items isrupees.
Test Case
: To minimise the expenditure, Chef can do the following:
- Purchase
- items.
Chef wanted to buy at least
items. The minimum money required for that isrupees.
Test Case
: To minimise the expenditure, Chef can do the following:
- Purchase
- items.
Thus, the minimum money required to buy
items is rupees.
No comments:
Post a Comment