atcoder#ARC139B. [ARC139B] Make N
[ARC139B] Make N
Score : points
Problem Statement
We have an integer . Find the minimum total cost to make by doing the following three kinds of operations any number of times in any order.
- Increase by , at a cost of .
- Increase by , at a cost of .
- Increase by , at a cost of .
Solve each of the test cases given to you.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Each test case is in the following format:
Output
Print lines, the -th of which should contain the answer to .
5
10 3 5 2 3 6
10 3 5 1 1000000000 1000000000
139 2 139 1 1 1
139 1 1 1 1 1
139 7 10 3845 26982 30923
11
10
1
139
436604
In the first test case, below is one way to make at the cost of , which is optimal.
- Increase by , making , at a cost of .
- Increase by , making , at a cost of .
- Increase by , making , at a cost of .
- Increase by , making , at a cost of .