Students Rank

Students Rank: There are N students who have taken a test. The students who have scored same marks are allocated the same rank. The program must accept the marks of the N students and print the rank of the Xth student.

Boundary Condition(s):
1 <= X <= N <= 1000
1 <= Marks of a student <= 100

Input Format:
The first line contains N.
The second line contains the marks of the N students.
The third line contains X.

Output Format:
The first line contains rank of the Xth student.

Example Input/Output 1:
Input:
5
55 60 55 50 60
4

Output:
3

Explanation:
Students 2 and 5 have scored 60 and are ranked 1.
Students 1 and 3 have scored 55 and are ranked 2.
Student 4 has scored 50 and is ranked 3.
Hence the rank of the 4th student is 3 and is printed as the output.

Example Input/Output 2:
Input:
5
50 50 50 55 50
4

Output:
1

a=int(input())
b=list(map(int,input().split()))
c=int(input())
d=b[c-1]
l=sorted(set(b))[::-1]
print(l.index(d)+1)

Previous Article

Function addTwoMatrices

Next Article

Chess Board Pattern

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *