Beat the Average CodeChef Solution | CodeChef Problem Solution 2022
There are students in a class. Recently, an exam on Advanced Algorithms was conducted with maximum score and minimum score . The average score of the class was found out to be exactly .
Given that a student having score strictly greater than the average receives an A
grade, find the maximum number of students that can receive an A
grade.
Input Format
- First line will contain , number of test cases. Then the test cases follow.
- The only line of each test case consists of three integers - the number of students, the maximum score and the average score respectively.
Output Format
For each test case, output in a single line, the maximum number of students who can receive A
grade.
Constraints
Sample Input 1
4
2 100 50
3 100 50
5 40 40
10 50 49
Sample Output 1
1
2
0
9
Explanation
Test case : There are students in the class. One of the possible values of scores is . Here, the average score is . Only the first student receives an A
grade. It can be shown that the maximum number of students receiving an A
grade is not more than .
Test case : There are students in the class. One of the possible values of the scores is . Here, the average score is . The students receiving an A
grade are students and . It can be shown that the maximum number of students receiving an A
grade is not more than .
Test case : There are students in the class. The average score and the maximum score is . Thus, the scores of all the students is . Since the score of all the students is equal to the average, none of them receive an A
grade.
Test case : It can be shown that the maximum number of students receiving an A
grade does not exceed .
Join Now for Solution:-
No comments:
Post a Comment