atcoder#ABC258D. [ABC258D] Trophy
[ABC258D] Trophy
Score : points
Problem Statement
We have a video game consisting of stages. The -th stage is composed of a movie lasting minutes and gameplay lasting minutes.
To clear the -th stage for the first time, one must watch the movie and do the gameplay for that stage. For the second and subsequent times, one may skip the movie and do just the gameplay.
In the beginning, only the -st stage is unlocked, and clearing the -th stage unlocks the -th stage.
Find the shortest time needed to clear a stage times in total. Here, if the same stage is cleared multiple times, all of them count.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 4
3 4
2 3
4 2
18
Here is one way to clear a stage times in minutes:
- Clear Stage . It takes minutes.
- Clear Stage . It takes minutes.
- Clear Stage again. It takes minutes.
- Clear Stage again. It takes minutes.
It is impossible to clear a stage times within minutes.
10 1000000000
3 3
1 6
4 7
1 8
5 7
9 9
2 4
6 4
5 1
3 1
1000000076