Sima Guang, a historian of the Song Dynasty, wrote a famous "theory of virtue and talent" in Zizhi Tongjian: "therefore, the perfection of talent and morality is called a saint, the death of talent and morality is called a fool, the victory of virtue is called a gentleman, and the victory of virtue is called a villain. If a gentleman takes the skill of man, he can't be a saint. If a gentleman takes it, he won't be a fool rather than a villain."
The scores of virtue and talent of a group of candidates are given. Please give the admission ranking according to Sima Guang's theory.
Input the first line and give 3 positive integers, respectively: N (≤ 105), that is, the total number of candidates; L (≥ 60) is the lowest score line for admission, that is, both moral score and talent score are not lower than L Candidates are eligible to be considered for admission; H (< 100) is the priority admission line - those whose moral score and talent score are not lower than this line are defined as "full of talent and virtue", and such candidates are ranked from high to low according to the total score of morality and talent; The candidates who can't get the talent score but get the moral score line belong to "virtue wins talent", which is also sorted according to the total score, but they are ranked behind the first category of candidates; Both moral and talent scores are lower than H. However, candidates whose moral score is not lower than that of talent belong to "both talent and morality" but still have "virtue wins talent", which are sorted according to the total score, but ranked behind the second category of candidates; Others reach the lowest line L Of candidates are also ranked according to the total score, but behind the third category of candidates.
subsequently N Line, each line gives the information of one candidate, including: admission card number, German score, in which the admission card number is an 8-digit integer, and German score is an integer in the interval [0, 100]. Numbers are separated by spaces.
The first line of output first gives the number of candidates who have reached the lowest score line M. Then M Each line outputs the information of one candidate according to the input format, and the candidates are sorted from high to low according to the rules described in the input. When there are many candidates with the same total score, they are arranged in descending order according to their moral score; If the scores are also in parallel, they will be output in ascending order of the admission number.
14 60 80 10000001 64 90 10000002 90 60 10000011 85 80 10000003 85 80 10000004 80 85 10000005 82 77 10000006 83 76 10000007 90 78 10000008 75 79 10000009 59 90 10000010 88 45 10000012 80 100 10000013 90 99 10000014 66 60
No blank lines at the end
12 10000013 90 99 10000012 80 100 10000003 85 80 10000011 85 80 10000004 80 85 10000007 90 78 10000006 83 76 10000005 82 77 10000002 90 60 10000014 66 60 10000008 75 79 10000001 64 90
No blank lines at the end
python code: (there is a timeout during operation, which has not been solved yet, but the idea is very clear and easy to understand)
n,l,h=map(int,input().split())#n is the total number of candidates; l is the lowest admission score line and H is the priority admission line a=[[0 for i in range(4)] for i in range(n)]#Two dimensional empty array n (14) x4 for i in range(n):#input data a[i],a[i],a[i]=map(int,input().split()) # print(a) m= 0 # Number of candidates reaching the lowest score line for i in range(n):#Update the a array, and the first m elements in a are the output samples to be sorted if a[i]>=l and a[i]>=l: m+=1 a[m-1], a[m-1], a[m-1]=a[i],a[i],a[i]#Update a array a[m - 1] = a[i] + a[i]#Write down the sum of virtue and talent # print(a) #The first m elements in a are the output samples to be sorted list1=#Store a class of examinees, whose virtues and talents are greater than 80 list2=#Only candidates who store virtue win, and only those whose virtue is greater than 80 are less than 80 list3=#Candidates who reach the bottom line have more virtue than talent list4=#Candidates who reach the bottom line are less virtuous than talented def sortlist(list):#Sort:#First arrange the total score, and then look at the German score for j in range(len(list)): for i in range(j, len(list)): if list[j] < list[i]: list[j], list[i] = list[i], list[j] elif list[j] == list[i]: if list[j] <= list[i]: list[j], list[i] = list[i], list[j] for i in range(m):#Start classification if a[i] >= h and a[i] >= h: list1.append(a[i]) elif a[i] >= h and a[i] < h: list2.append(a[i]) elif a[i] < h : if a[i] > a[i]: list3.append(a[i]) else: list4.append(a[i]) sortlist(list1) # print(list1)#13,12,3,11,4 sortlist(list2) # print(list2)#7,6,5,2 sortlist(list3) # print(list3)#14 sortlist(list4) # print(list4)#8,1 def out_put(list):#output for i in range(len(list)): print("%d %d %d" % (list[i], list[i], list[i])) print(m) out_put(list1) out_put(list2) out_put(list3) out_put(list4)