#C6622. Minimum Number of Teams
Minimum Number of Teams
Minimum Number of Teams
You are given N employees, each having a certain skill level. Your task is to group these employees into teams such that the total skill of each team does not exceed a given threshold T. The goal is to minimize the number of teams formed.
Note: You can form a team with any number of employees as long as their combined skill does not exceed T. It is guaranteed that each individual employee's skill is less than or equal to T, so each employee can form a team on their own if needed.
The problem can be modeled using a greedy strategy where you sort the employees by their skills and then try to pair the most skilled employee with the least skilled that can fit into the team without exceeding the threshold. If no pairing is possible, the employee forms a team alone.
The formula for a team's skill sum can be represented in \( \LaTeX \) as:
\[ S = \sum_{i \in \text{team}} s_i \leq T \]inputFormat
The first line of input contains two integers N and T, where N is the number of employees and T is the maximum allowed skill sum per team.
The second line contains N space-separated integers, each representing the skill level of an employee.
outputFormat
Output a single integer representing the minimum number of teams that can be formed such that for each team, the sum of the skill levels does not exceed T.
## sample6 10
2 3 7 1 8 4
3