#C1761. Minimum Tables
Minimum Tables
Minimum Tables
You are given a series of test cases. For each test case, you are provided with a number of groups of guests, where each group has a size of either 1, 2, 3, or 4. Your task is to determine the minimum number of tables required to seat all guests, given that each table seats exactly $4$ guests and every guest must be seated at one table.
Note: You may need to combine different groups to fill a table optimally. For example, a group of 3 can be paired with a group of 1. Use a greedy approach to pair and partition the groups optimally.
inputFormat
The input is read from standard input (stdin) and is structured as follows:
- The first line contains an integer
T
, the number of test cases. - For each test case, the first line contains an integer
n
, representing the number of groups. - The second line contains
n
space-separated integers, each indicating the size of a group.
Constraints: Group sizes will be one of these values: 1, 2, 3, or 4.
outputFormat
For each test case, output a single integer on a separate line: the minimum number of tables required to seat all groups.
## sample2
5
1 2 3 4 2
3
2 2 2
3
2
</p>