#P11044. [蓝桥杯 2024 省 Java B] 食堂
[蓝桥杯 2024 省 Java B] 食堂
Problem Description
In S School, there are double rooms, triple rooms, and quadruple rooms. In the canteen, there are four-seat tables and 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 lines.
The first line is a positive integer , which is the number of test cases.
The next lines each contain five non-negative integers , describing one test case.
Output Format
Output lines. Each line contains one integer, the answer for the corresponding test case.
2
3 0 1 0 1
0 2 2 1 1
6
10
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 .
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 .
[Constraints and Notes for Test Cases]
For of the test cases, it is guaranteed that .
For of the test cases, it is guaranteed that , and .
Translated by ChatGPT 5