pat-B-1015. The moral Theory (25)

Source: Internet
Author: User

1015. Morality theory (25) time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen, Li

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
Idea: Pay attention to the structure of multi-level sequencing, in order to prevent timeouts, please use scanf and printf
1#include <bits/stdc++.h>2 using namespacestd;3 intNum,low,first;4 5 structNode6 {7     intNo;8     intde;9     intCai;Ten }; One  A BOOLCMP (node x, node Y) - { -  the     if(x.de+x.cai!=y.de+Y.cai) -         return(X.DE+X.CAI) > (y.de+Y.cai); -     Else if(x.de!=y.de) -         returnX.de>y.de; +     Else -         returnx.no<y.no; + } A  at intMain () - { - Node Stu; -Vector<node> v1,v2,v3,v4;//v1 de only double, V2 de wins only, V3 only de, still de wins, V4 pass line goalkeeper -     intCount=0; -scanf"%d%d%d",&num,&low,&First ); in      for(intI=0; i<num; i++) -     { toCin>>stu.no>>stu.de>>Stu.cai; +  -         if(Stu.de>=low&&stu.cai>=low)//Edge Input Edge classification the         { *count++; $             if(Stu.de>=first&&stu.cai>=first)//Germany is the only doublePanax Notoginseng V1.push_back (stu); -             Else  if(Stu.de>=first)//Germany wins the V2.push_back (stu); +             Else  if(STU.DE&GT;=STU.CAI)//only the German and the Dead de Sheng A V3.push_back (stu); the             Else +V4.push_back (Stu);//Pass line goalkeeper -         } $     } $  -Sort (V1.begin (), V1.end (), CMP);//Sort - sort (V2.begin (), V2.end (), CMP); the sort (V3.begin (), V3.end (), CMP); - sort (V4.begin (), V4.end (), CMP);Wuyi  theprintf"%d\n", count);//Number of Passes -      for(intI=0; I<v1.size (); i++)//output in sequence Wuprintf"%d%d%d\n", V1[i].no,v1[i].de,v1[i].cai); -      for(intI=0; I<v2.size (); i++) Aboutprintf"%d%d%d\n", V2[i].no,v2[i].de,v2[i].cai); $      for(intI=0; I<v3.size (); i++) -printf"%d%d%d\n", V3[i].no,v3[i].de,v3[i].cai); -      for(intI=0; I<v4.size (); i++) -printf"%d%d%d\n", V4[i].no,v4[i].de,v4[i].cai); A     return 0; +}

pat-B-1015. The moral Theory (25)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.