Question: Code in C with comments: We have to create the regionals team - this year, it turns out there's no limit to how many students

Code in C with comments:

We have to create the regionals team - this year, it turns

out there's no limit to how many students can participate, since the

contest will be held over Zoom. So we want to create a

We have to create the regionals team - this year, it turns out there's no limit to how many students can participate, since the contest will be held over Zoom. So we want to create a team with the maximum number of students. But you also know that a team should be balanced. It means that the programming skill of each pair of students in a created team should differ by no more than 5, our lucky number. Your task is to report the maximum possible number of students in a balanced team. Input The first line of the input contains one integer n (1sns2-105) the number of students. The second line of the input contains n integers a1,a2.,an (1sas10), where a; is the programming skill of the i-th student. Output Print one integer - the maximum possible number of students in a balanced team. Examples

Step by Step Solution

3.31 Rating (139 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include include Note prev always contains max team size calculated and intially 0 int balancedTeam... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!