The Song Dynasty historian Sima Guang in "the Capital Governance Tong Jian" has a famous "The Moral Only Theory": "is therefore only then the virtuous all says the sage, only then the German and the death is the Fool, the German wins only then is said the gentleman, only then wins the moral to be the villain. Whoever takes the technique of the person, Gou not saints, gentleman and with it, with the villain, not if the fool. ”
Now give a number of candidates of the German score, please according to Sima Guang theory to give admission rankings.
Input format:
Enter the 1th line to give 3 positive integers, namely: N (<=105), that is, the total number of candidates, L (>=60), for the admission of the minimum score, that is, the German and want $ are not less than L candidates are eligible to be considered for admission; H (<100), the priority line of admission-- The German and want $ are not below this line is defined as "only de full", such candidates by virtue of the total score from high to low ranking; want $, but the German division to the line of a class of candidates belonging to the "Desheng", but also according to the total number of candidates, but ranked in the first category after the candidate, Germany want $ are lower than H, but the score is not less than want $ candidates belong to "only Germany and death" "De Sheng", ranked by total, but ranked after the second category of candidates, other people who reached the minimum line L were ranked by total, but ranked after the third category of candidates.
Then n lines, each line gives a candidate's information, including: The ticket number, German points, want $, where the ticket number is a 8-bit integer, Germany is divided into the interval [0, 100] integer. The numbers are separated by a space.
Output format:
Output line 1th first gives the number of candidates to reach the minimum fraction m, followed by M, each line in the input format to output a candidate's information, candidates according to the rules indicated in the input from high to low sort. When a certain number of candidates in the same time, according to their German points in descending order; If the German points are also tied, the ticket number in the ascending output.
Input Sample:
14 60 8010000001 64 9010000002 90 6010000011 85 8010000003 85 8010000004 80 8510000005 82 7710000006 83 7610000007 90 7810 000008 75 7910000009 59 9010000010 88 4510000012 80 10010000013 90 9910000014 66 60
Sample output:
1210000013 90 9910000012 80 10010000003 85 8010000011 85 8010000004 80 8510000007 90 7810000006 83 7610000005 82 771000000 2 90 6010000014 66 6010000008 75 7910000001 64 90
Package Com.wpr.demo2;import Java.util.collections;import Java.util.linkedlist;import java.util.List;import Java.util.scanner;public class Main {static Class Student implements Comparable<student>{int Id;int Score1;int Score2; Student (int a,int b,int c) {this.id = A;this.score1=b;this.score2=c;} @Overridepublic int compareTo (Student o) {if (This.score2+this.score1 >o.score1+o.score2) {return 1;} else if (this.score2+this.score1==o.score1+o.score2) {if (This.score1 > O.score1) {return 1;} else if (this.score1==o.score1) {return o.id-this.id;}} return-1;}} public static void Main (string[] args) {Scanner scan = new Scanner (system.in); student[] Stus = new Student[scan.nextint ()];int low = Scan.nextint (), int high = Scan.nextint (); list<student> stu1 = new linkedlist<> (); list<student> STU2 = new linkedlist<> (); list<student> stu3 = new linkedlist<> (); list<student> stu4 = new linkedlist<> (); for (int i=0;i<stus.length;i++) {Stus[i] = new Student (SCAN.nextint (), Scan.nextint (), Scan.nextint ()); if (Stus[i].score1>=low && stus[i].score2>=low) {if (stus[ I].score1>=high&&stus[i].score2>=high) {Stu1.add (stus[i]);} else if (Stus[i].score1>=high) {Stu2.add (stus[i]);} else if (stus[i].score1>=stus[i].score2) {Stu3.add (stus[i]);} Else{stu4.add (Stus[i]);}} Collections.sort (Stu1,collections.reverseorder ()); Collections.sort (Stu2,collections.reverseorder ()); Collections.sort (Stu3,collections.reverseorder ()); Collections.sort (Stu4,collections.reverseorder ()); System.out.println (Stu1.size () +stu2.size () +stu3.size () +stu4.size ()); for (Student s:stu1) {System.out.println (s.id + "+s.score1+" "+s.score2);} for (Student s:stu2) {System.out.println (s.id+ "" +s.score1+ "" +s.score2 ");} for (Student s:stu3) {System.out.println (s.id+ "" +s.score1+ "" +s.score2 ");} for (Student s:stu4) {System.out.println (s.id+ "" +s.score1+ "" +s.score2);}}}
Java run timed out, tomorrow write C or C + + version
1015. Morality (25)