Carrot Click Game
InterviewTime limit2sMemory limit1024 MB
Given N speed effects with costs A_i and speed gains B_i, find the most carrots Eric can hold after K seconds of clicking and buying.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Greedy
- Solved
- No attempts yet
Problem
Eric had too much free time during his vacation, so he decided to make a game called Carrot Click Game and play it himself.
At the start of the game, Eric has 0 carrots and is 1.
Every second, he can do one of the following two actions.
- Click the mouse to get carrots.
- Choose an integer () and pay carrots to buy the -th speed effect. Right after the purchase, increases by . (A speed effect bought earlier can be bought again.)

Eric used up all his energy building the game, so find the maximum number of carrots he can have after playing for seconds.
Input
The first line contains two integers and , separated by a space.
Each of the next lines contains two integers and , separated by a space, for the -th speed effect.
Output
Print the maximum number of carrots Eric can have after playing the game for seconds.