Array ( [0] => [1] => questions [2] => HackwithInfy-Previous-Questions [3] => Class-Student ) HackwithInfy Previous Questions | Class Student | THE INQUISITIVE





Class Student

LEVEL:Beginner

Description

Dia, Sam, and Robert are the three students of a same class. You know their marks in N subjects. Your job is to find their ranks according to their score.

Input Format

N, integer denoting number of subjects.
3 array of integers, denoting marks of Dia, Sam and Robert respectively in N subjects.

Output Format

Print the ranks in order, seperated by space


Example 1:

Input
3
23 34 23
32 53 23
55 22 67
Output
3 2 1
Example 2:

Input
5
25 35 45 55 65
66 21 41 19 29
31 44 24 10 32
Output
1 2 3
Example 3:

Input
7
25 35 45 55 65 11 29
66 21 41 19 29 77 21
31 44 24 10 32 49 64
Output
2 1 3

oops

Login to see Discussion




Approach

Approach:
Step-1: Calculate sum of all the scores for three students
Step-2: Add the resultant sum of all n (here n=3) students to array and sort the list in descending order
Step-3: From reversed sorted array, check the ith element with all the three members scores and increment their rank with 'i' value
Step-4: Repeat Step-3, for n times (here n is constant, i.en=3)


Note :

Let us know if you can come up with a better approach, mail us at support@theinquisitive.in Your approach will be reviewed and posted with credits to you.

oops

Login to see Solution