The final result of the test will depend upon the following factors :
1. The remaining oxygen level should only be accepted if it is in the range between [1, 100] both inclusive else the oxygen level will be marked as 0.
2. If the calculated maximum average oxygen remaining value of trainees is below 70, then declare the trainees as unfit with the meaningful message as “Unfit.”
3. The average remaining Oxygen level should be rounded.
For Example :
Output for the above case will be
Trainee1
Unfit
Trainee3
Because the maximum average is 70 which is in the range and Trainee 1 and 3 both have the same value.
Trainee 2 is unfit because the average is below 70.
The first line of input contains an integer 'T' which denotes the number of test cases to be run. Then the test cases follow.
The next 3 lines of each test case contain 3 space-separated integers denoting the oxygen level of each trainee after each round.
Output Format :
For each test case, print the fittest trainee. If more than one trainee has the same highest average oxygen level then print all of them in increasing order.
Print “Unfit” if the average oxygen level is less than 70.
Print the output of each test case in a separate line.
Note :
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= ‘T’ <= 100
1 <= ‘OXYGEN[i][j]’ <= 100
Where ‘OXYGEN[i][j]’ denotes the oxygen level of 'ith' candidate after 'jth' round.
Time Limit: 1 sec
2
10 50 30
30 80 90
60 90 80
90 90 90
70 70 70
0 101 98
Unfit
Unfit
Trainee3
Trainee1
Unfit
For the first test case:
Following are the average of remaining oxygen levels of 3 trainees:
1. (10 + 50 + 30) / 3 = 30, which is less than 70 so the trainee is unfit.
2. (30 + 80 + 90) / 3 = 66.66, which becomes 66 on rounding up which is less than 70 so the trainee is unfit.
3. (60 + 90 + 80) / 3 = 76.66, which becomes 76 on rounding up which is in the range and maximum among all.
For the second test case:
Following are the average of remaining oxygen level of 3 trainees:
1. (90 + 90 + 90) / 3 = 90, so the trainee’s average oxygen level is in the range.
2. (70 + 70 + 70) / 3 = 70, so the trainee’s average oxygen level is in the range.
3. (0 + 0 + 98) / 3 = 66.33. Here, we added 0 instead of 101 because as given in the problem the value out of the range [1, 100] is to be treated as 0. 66.33 on rounding up gives 66 which is less than 70 so the trainee is unfit.
Trainee1 is the fittest among all and trainee3 is unfit.
1
55 56 84
94 85 76
12 21 34
Unfit
Trainee2
Unfit
For the first test case:
Following are the average of remaining oxygen level of 3 trainees:
1. (55 + 56 +84) / 3 = 65, which is less than 70 so the trainee is unfit.
2. (94 + 85 +76) / 3 = 85, which is in the range.
3. (12 + 21 + 34) / 3 = 22.33, which becomes 22 on rounding up. which is less than 70 so the trainee is unfit.
Trainee2 is fittest among all and trainee 1 and 3 are Unfit.
Try to use brute force approach in this problem by calculating the average of all the rounds.
The idea behind this approach is to calculate the average of all the rounds and store them in an array/list and then calculate the maximum of all the average remaining oxygen levels. If more than one have the same value then print the trainee number and if average is less than 70 then simply print “Unfit”.
Here is the complete algorithm:
O(1).
Because we are iterating 2D array/list ‘OXYGEN’ of size 3 X 3 so the overall iterations will be constant and hence the overall time complexity will be O(1).
O(1).
Because we are not using any extra space to calculate the final result.