Universal Cup Judging System

Universal Cup

Süre Sınırı: 1.0 s Bellek Sınırı: 256 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

Description

You are the captain of the school programming competition team, leading your classmates to Chongqing to participate in the CCPC. According to the team's tradition, as the captain, you need to treat your classmates to a meal, and you plan to eat the local specialty hot pot.

According to statistics, there are $x$ students in the team who only accept spicy food, $y$ students who only accept non-spicy food, and $z$ students who accept both spicy and non-spicy food. The hot pot restaurant you visit offers three types of pots:

  • Spicy pot, which can serve at most two students who accept spicy food, costing $a$ yuan per serving.
  • Mixed pot, which can serve at most one student who accepts spicy food and at most one student who accepts non-spicy food, costing $b$ yuan per serving.
  • Non-spicy pot, which can serve at most two students who accept non-spicy food, costing $c$ yuan per serving.

You want to know the minimum amount of money needed to ensure that all students can eat hot pot according to their preferences.

Input

There are multiple test cases in a single test file. The first line of the input contains a single integer $T$ ($1 \le T \le 2025$), indicating the number of test cases.

For each test case:

  • Each line contains $6$ positive integers $x, y, z, a, b, c$ ($1 \le x, y, z, a, b, c \le 2025$), representing the number of students in each category and the prices of the three types of hot pots.

Output

For each test case, output a single integer on a single line, representing the minimum possible cost to ensure that all students can eat hot pot according to their preferences.

Example

Sample Input 1

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

Sample Output 1

8
3
9
39
29
26

Note

  • In the first example, you can let all mixed preference students eat spicy food, then order three spicy pots and one mixed pot, with a total cost of $1 \times 3 + 5 \times 1 = 8$.
  • In the second example, you can let the mixed preference students have two eat spicy and two eat non-spicy, then order three mixed pots, with a total cost of $1 \times 3 = 3$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.