I was doing some studying to improve my chances for an upcoming programming test, and I came across this problem. Trying to understand this leaves me quite confused about the correct answer and algorithm I need to develop. Any guidance someone can give me in how to go about this?
You are hosting a sporting match with N athletes, and there are various events in the competition such as weight lifting and running. Each event is worth 1 or 2 points.
The scoreboard shows that the ith player has a score of Ci. Note that Ci is a positive integer equal to the sum of the point values of all the events they have completed.
The scoreboard does have any other details, such as the number of competitive events, nor their point values.
Write a program to determine the minimum possible number of competitive events in the sporting match for N athletes of an array of C scores.
Example If the scoreboard says 1 2 3 4 5 6 and there are 6 athletes, then the minimum number of competitive events should be 4
I try to solve this and keep thinking the answer should be '3' - for the events to either be 1 or 2 points, then for someone to get a 6 (the highest score) the fastest way would be 2+2+2 = 6 or 3 events. If there are 3 events, then it means every other score on the board would be satisfied (1 means someone got a 1 on the first event, but didn't yet do the other 2 events. a 2 means the athlete either completed one or two events, with either a 2 or two 1's, etc). What am I missing?
Thank you!