#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 NN different roles of professional players, and for the ii-th role there are AiA_i 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:

  1. A group of 55: Each team consists of exactly 55 players.
  2. Role exclusivity: The 55 players in the same team must come from 55 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 TT, which denotes the number of test cases.

Then follow TT test cases, each in the following format:

  • The first line contains an integer NN, which denotes the number of role types.
  • The second line contains NN integers A1,A2,…,ANA_1, A_2, \dots, A_N, where AiA_i denotes the number of players of the ii-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 55 players, each in a different role, so they can form exactly 11 team.

In the second test case, there are 1010 players, which can be divided into 22 teams. One valid assignment is: Team 1 consists of roles 1,2,3,4,51, 2, 3, 4, 5; Team 2 consists of roles 1,2,3,4,61, 2, 3, 4, 6.

In the third and fourth test cases, no grouping plan satisfies the conditions.

Constraints.

For 30%30\% of the testdata: 1≤T≤51 \le T \le 5, 1≤N≤201 \le N \le 20, 0≤Ai≤1000 \le A_i \le 100.

For 100%100\% of the testdata: 1≤T≤1031 \le T \le 10^3, 1≤N≤1051 \le N \le 10^5, 0≤Ai≤1090 \le A_i \le 10^9, and it is guaranteed that the sum of NN over all test cases does not exceed 2×1052 \times 10^5.

Translated by ChatGPT 5