#P16235. [蓝桥杯 2026 省 B] 蓝桥竞技
[蓝桥杯 2026 省 B] 蓝桥竞技
Problem Description
Xiao Lan, as the team manager of the esports club "Lanqiao Esports", is facing a huge management crisis. The club has currently signed different roles of professional players, and for the -th role there are players.
To participate in the upcoming "Rift 5v5", Xiao Lan must assign all players in the club into teams. No one is allowed to sit on the bench.
According to the strict rules of the organizing committee, a valid team must satisfy the following conditions:
- A group of : Each team consists of exactly players.
- Role exclusivity: The players in the same team must come from completely different roles.
Now, please help Xiao Lan determine whether, with the current number of players, there exists a grouping plan that can distribute all players exactly, and every team satisfies the competition rules.
Input Format
The first line contains an integer , which denotes the number of test cases.
Then follow test cases, each in the following format:
- The first line contains an integer , which denotes the number of role types.
- The second line contains integers , where denotes the number of players of the -th role.
Output Format
For each test case, if there exists a grouping plan that meets the conditions, output T; otherwise output F.
4
5
1 1 1 1 1
6
2 2 2 2 1 1
5
1 1 1 1 2
6
3 1 1 1 2 2
T
T
F
F
Hint
Sample Explanation.
In the first test case, there are players, each in a different role, so they can form exactly team.
In the second test case, there are players, which can be divided into teams. One valid assignment is: Team 1 consists of roles ; Team 2 consists of roles .
In the third and fourth test cases, no grouping plan satisfies the conditions.
Constraints.
For of the testdata: , , .
For of the testdata: , , , and it is guaranteed that the sum of over all test cases does not exceed .
Translated by ChatGPT 5