Mock CCC '26 J2 - Free Throws
View as PDFMock Canadian Computing Competition: 2026 Stage 1, Junior #2
There are players on a basketball team, and during a practice drill, each player shoots
free throws. Each player also has a certain number of free misses
.
The team will run laps, where
represents the maximum penalty of a player. The penalty of a player is the number of shots they miss beyond their free misses. For example, if a player misses
shots but has
free misses, their penalty is
. If that player misses
or fewer, their penalty is
.
The team misses a total of baskets, however it is unknown how many shots each player missed. Determine the minimum value of
.
Constraints
Input Specification
The first line contains
The next line contains integers. The
integer represents
Output Specification
Output the minimum number of laps the team must run.
Sample Input 1
6 4 21
4 1 2 1
Output for Sample Input 1
4
Explanation of Output for Sample Input 1
Consider the following distribution of missed shots, without the free misses: . Taking into account the free misses for each player
, we get the following penalty distribution:
. Thus, the number of laps the team must run is
. It can be shown that this is the minimum value of
.
Sample Input 2
8 10 52
9 4 5 11 8 2 3 2 10 6
Output for Sample Input 2
0
Explanation of Output for Sample Input 2
All shots missed by the team can be covered by players' free misses collectively. One such distribution of missed shots is: . Thus, the minimum value of
is 0.
Sample Input 3
5 2 9
4 0
Output for Sample Input 3
4
Explanation of Output for Sample Input 3
can be obtained with the following distribution of missed shots:
.
Comments