Count how many 3-person teams can be formed when each team must have a total skill level below a limit.
You are given the skills of participants and a threshold .
A team can be formed by choosing exactly 3 participants. A team is considered valid only if the sum of their skills is strictly less than .
Your task is to determine how many valid teams can be formed from the given participants.
Since the answer may be large only in more general settings, use a standard integer type suitable for counting teams.
For every possible group of three participants, check whether the sum of their skills is below the limit, and count it if it is.
Print a single integer — the number of valid teams of size 3 whose skill sum is strictly less than .
These bounds are consistent with a brute-force or lightly optimized counting approach.
Example 1
Input
3 6 1 2 3
Output
1
Explanation
There is only one team of 3 participants, and their sum is 1 + 2 + 3 = 6, which is not strictly less than 6. So the answer is 0.
Note: if the threshold were 7, the answer would be 1. This example illustrates the strict comparison requirement.
Example 2
Input
4 6 1 1 1 1
Output
4
Explanation
Every choice of 3 participants has sum 3, which is strictly less than 6. There are C(4,3) = 4 such teams.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.