-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcibil score.py
More file actions
43 lines (36 loc) · 1.02 KB
/
cibil score.py
File metadata and controls
43 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from operator import itemgetter
def reverse(a,b):
temp=0
temp=a
a=b
b=temp
#print(a,b)
return a,b
def cibil(number):
list1=[]
for i in range(number):
na, c, r=list(map(str, input().split()))
list1.append([na,c,r])
#print(list1)
list2 = sorted(list1, key=itemgetter(1), reverse=True)
for i in range(len(list2)-1):
if list2[i][1]==list2[i+1][1]:
if (list2[i][2] > list2[i + 1][2]):
list2[i], list2[i + 1] = reverse(list2[i], list2[i + 1])
elif list2[i][2]==list2[i+1][2]:
if (list2[i][0]<list2[i+1][0]):
list2[i], list2[i + 1] = reverse(list2[i], list2[i + 1])
else:
list2[i], list2[i + 1] = reverse(list2[i], list2[i + 1])
#print(list2)
pos=int(input())
list3=(list2[pos-1])
x, y =list3[0],list3[1]
return x, y
T=int(input())
list4=[]
for i in range(T):
num=int(input())
list4.append(cibil(num))
for item in list4:
print(item[0],item[1])