Mock CCC '20 Contest 1 S2 - Jonathan is Hungry 😰

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Jonathan typically doesn't eat lunch. Today, he is helping Thornhill's Tech Crew to earn some profit, and to do this, he is selling burgers!

There are 2 types of burgers that Jonathan can make, which are:

  • Beef: 2 buns, 1 meat patty

  • Vegetarian: 2 buns, 1 veggie patty

You have b buns, x meat patties and v veggie patties. You sell one beef burger for p dollars and one veggie burger for q dollars. What is the maximum profit you can make?

You have Q queries you need to answer.

Input Specification

The first line of input will contain Q, 1 \le Q \le 1000.

The next line of input will contain the first line of each query b, x, and v, 1 \le b, x, v, \le 100, respectively.

The second line of each query will contain p and q, 1 \le p, q, \le 100.

Output Specification

For each query output an integer on a separate line, which should be the maximum profit you can achieve.

Sample Input 1

5
2 4 1
7 2
5 5 1
3 9
5 2 4
2 8
4 3 1
6 4
3 3 1
10 1

Sample Output 1

7
12
16
12
10

Comments

There are no comments at the moment.