The first line contains two integersand
(
), representing the initial amount of sun you have and the number of rounds the game will be played.
The second line contains two integersand
(
), describing the attributes of the first type of sunflower.
The third line contains two integersand
(
), describing the attributes of the second type of sunflower.
Output a single integer, which is the maximum amount of sun you can have after
rounds.
In the first sample test case, Alice starts with
sun and has
rounds to plant sunflowers. Here is the optimal strategy:
In the first round, spend sun to plant both types of sunflowers. At the end of the round,
sun would be generated.
In the second round, spend sun to plant the second type of sunflower and keep
sun. At the end of the round,
sun would be generated, and your sun would increase to
.
In the third round, do not buy new sunflowers. After collecting sun for this round, you would have
sun.