Skip to content

Instantly share code, notes, and snippets.

@officialcjunior
Last active October 26, 2019 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save officialcjunior/790c39a798d336d28f8782d0b41521c4 to your computer and use it in GitHub Desktop.
Save officialcjunior/790c39a798d336d28f8782d0b41521c4 to your computer and use it in GitHub Desktop.
This is the solution for problem 1017A The Rank from codeforces.com, written in Python 3.
n=int(input())
S=[]
for i in range (n):
A=[int(i) for i in input().split()]
S.append(sum(A)) #S will now have the total marks of all students
if S[0]==max(S):
print("1")
exit() #We handle the case of Thomas being ranked 1 seperately.
thomas=S[0]
rank=1
S.sort(reverse=True)
for i in S:
if i==thomas:
print(rank)
break
else:
rank += 1 #Then for every i not Thomas' total marks, we increase the rank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment