P11044 [Lanqiao Cup 2024 NOI Qualifier Java B] Canteen
Description
In S School, there are $a_2$ double rooms, $a_3$ triple rooms, and $a_4$ quadruple rooms. In the canteen, there are $b_4$ four-seat tables and $b_6$ six-seat tables. The school wants to arrange the students to eat in the canteen, and it must be ensured that all students from the same dorm room sit at the same table. What is the maximum number of students that can be served at the same time?
Input Format
**This problem uses multiple test cases.**
The input has $q + 1$ lines.
The first line is a positive integer $q$, which is the number of test cases.
The next $q$ lines each contain five non-negative integers $a_2, a_3, a_4, b_4, b_6$, describing one test case.
Output Format
Output $q$ lines. Each line contains one integer, the answer for the corresponding test case.
Explanation/Hint
**[Sample Explanation]**
For the first test case, there is only one six-seat table, so at most three double rooms can be arranged to eat. The answer is $(2 + 2 + 2) = 6$.
For the second test case, use one six-seat table to seat two triple rooms, and use one four-seat table to seat one quadruple room. The answer is $(3 + 3) + (4) = 10$.
**[Constraints and Notes for Test Cases]**
For $20\%$ of the test cases, it is guaranteed that $a_2 + a_3 + a_4 \leq 8$.
For $100\%$ of the test cases, it is guaranteed that $q \leq 100$, and $b_4 + b_6 \leq a_2 + a_3 + a_4 \leq 100$.
Translated by ChatGPT 5