#P9225. 「PEOI Rd1」寻宝(treasure)
「PEOI Rd1」寻宝(treasure)
Problem Description
One day, wrzSama was treasure hunting, and suddenly fell into a magical room. There are machines in this room. Machine can produce diamonds.
More specifically, wrzSama can spend time to start machine , and it will produce diamonds. These machines have a very special property: every time he uses machine , its start-up time increases by . This means that when he wants to get these diamonds for the second time, it will take time. The time keeps increasing in this way, and the -th start will take time.
wrzSama needs to obtain at least diamonds to get the treasure. Please find the minimum total time required.
Input Format
The first line contains a positive integer .
The second line contains positive integers, representing .
The third line contains positive integers, representing .
Output Format
Output one positive integer in a single line, which is the answer.
3
1 2 3
3 2 1
3
3
1 2 100
1 2 1
5
4
1 2 100 100
1 2 1 1
15
Hint
Sample Explanation
Sample 1: directly obtain , costing time 3.
Sample 2: obtain 2 copies of , costing time 3, then spend time 2 to obtain one . In this way, wrzSama can get .
Sample 3: obtain 2 copies of and 3 copies of .
Constraints
This problem uses bundled tests.
| Subtask | Score | Special Constraints |
|---|---|---|
| None |
For of the testdata, it is guaranteed that and .
Translated by ChatGPT 5