## DMOPC '21 Contest 2 P1 - Bosses

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Time for some video games!

Bob is playing a video game with levels, where the boss on the -th level has a power of . Bob initially has no power. In order to clear a level, Bob needs to have at least as much power as the boss on that level. Also, Bob may only attempt level after clearing all levels with .

Thankfully, Bob can power up! He can spend seconds to gain unit of power permanently by increasing his HP, or he can spend seconds to drink a potion, also netting him unit of power but only for the next boss fight. He may perform either of these actions at any point and as many times as he wants.

Bob wants to clear all the levels. How long does he need?

#### Input Specification

The first line will contain three space-separated integers, , and .

The next line will contain space-separated integers .

#### Output Specification

Output a single integer, the minimum time Bob needs to spend to beat all the bosses.

#### Sample Input

3 5 3
1 3 20

#### Sample Output

66

#### Explanation

It can be proven that it is optimal to first increase Bob's HP by unit, beat the boss on the first level, increase Bob's HP by more units, beat the boss on the second level, and finally drink potions in order to beat the boss on the third level, for a total of seconds.