Bling

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Trapped at home in quarantine, Johan tries to keep madness at bay and fend off isolation by playing Critter Junction, a social simulation video game.  One of the main aspects of the game is collecting and harvesting various types of resources, in order to gain Bling, the currency of the game.  Johan specializes in running the fruit% category of the game, in which the goal is to obtain the maximum amount of Bling in 4040 days using only fruits and no other resources.

Each fruit can be sold for 100100 Bling, or planted to become a fruit tree (but not both).  Every three days, starting on the third day after it was planted, a fruit tree yields three new fruits.

There are also some more exotic fruits that can be bought from the neighboring village.  Once per day, the player can travel to the neighboring village and pay 400400 Bling to buy a single exotic fruit which you can then plant or sell already on the same day.  Analogously to normal fruits, these exotic fruits can be planted into exotic fruit trees which yield three exotic fruits every three days.  Each exotic fruit can be sold for 500500 Bling.

Any number of fruits/exotic fruits can be harvested, sold and planted during a day (subject to availability of course, e.g. it is not possible to sell more fruits than you actually have), but at most a single exotic fruit can be bought.  These activities can be done in any order, so it is for instance possible within the same day to first harvest a few fruits (exotic or not), then sell those fruits for Bling, then use that Bling to buy an exotic fruit, and then either plant or sell that exotic fruit.

Given the current state of Johan's fruit farm, what is the maximum amount of Bling he can achieve in the remaining time?

입력

The input consists of a single line containing six integers dd, bb, ff, t_0t\_0, t_1t\_1 and t_2t\_2 (1d401 \le d \le 40, 0b5000 \le b \le 500, and 0f,t_0,t_1,t_21000 \le f, t\_0, t\_1, t\_2 \le 100), where:

  • dd is the number of remaining days Johan has
  • bb is the current amount of Bling Johan has.
  • ff is the current number of fruits Johan has.
  • t_it\_i is the number of fruit trees Johan has that will yield crop ii days from today (for 0i20 \le i \le 2).

Johan currently does not have any exotic fruits or exotic fruit trees.

출력

Output a single integer: the maximum amount of Bling Johan can have after playing dd days.