#A0000. 卖水果

卖水果

Title Description

33DAI and Kitten are currently playing a game. There are four common fruits in the game: "lime", "apple", "banana", and "sato".

Today Kitten picked nn (ensuring that nn is a multiple of 1010 ) of each fruit, totaling 4n4n , and handed them over to 33DAI for sale. 33DAI has three sales strategies:

  1. All four types of fruits can be used to make jam, and 10 10 of a certain fruit can be used to make a corresponding jar of jam. The price of all four types of jam is xx yuan.
  2. You can use two fruits of each type, for a total of 88 , to make a fruit salad. The price of the fruit salad is yy yuan.
  3. Of course, it can also be directly roasted and sold. The unit prices for the four types of fruits roasted and sold are a1a1 , a2a2 ,a3 a3, and a4a4 , respectively.

In fact, fresh fruits can also be sold, but the price of fresh fruits in the game is inevitably lower than that of ripe ones, so 33DAI will never adopt this method.

Now 33DAI wants to choose one of the sales strategies to sell all the goods. Please help him calculate which sales strategy can maximize the profit!

Attention: Only one sales strategy is allowed and cannot be mixed. For example, lime cannot be made into jam, while apples are roasted and sold

Input format

The first row consists of three integers n,x,yn, x, y separated by spaces. The next line consists of four integers a1,a_1, a_2, a3,a_3, a_4 $separated by spaces, with the meanings as described in the question.

Output format

One integer per line represents the maximum profit that 33DAI can obtain.

100 3100 1388
190 390 290 220
one hundred and twenty-four thousand

Example 1 Explanation

The corresponding revenue for the three sales plans is $12400069400109000, so the first sales plan is chosen.

This example is the price tested by 33DAI in a real game. The options for 33DAI are lime and peach jam for sale, and apples roasted and sold. Bananas were left to eat on their own due to their high efficiency in restoring physical energy. Of course, the 33DAI in this question is quite clumsy, and I definitely can't come up with such a perfect solution.

Data scale and agreement

For data of 100%100 \% 1n,x,y,a1,a2,a3,a4104 1\le n, x,y,a_1,a_2,a_3,a_4\le 10^4, Ensure that nn is a multiple of 1010 .

-Subtask 1 ($30 points): Ensure the highest profit from making jam. -Subtask 2 ($30 points): Ensure the highest profit from making salad. -Subtask 3 ($40 points): No special restrictions.

What is a subtask?: Each subtask will have a certain number of test points, and you can only receive the score for the current subtask after passing all the test points of the current subtask.