# pat1062. Talent and Virtue (25)

Source: Internet
Author: User

1062. Talent and Virtue (25) time limit MS Memory limit 65536 KB code length limit 16000 B procedure StandardAuthor Chen, Li

About years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people ' s talent and VI Rtue. According to He theory, a man being outstanding in both talent and virtue must is a "sage (sage)"; Being less excellent but with one's virtue outweighs talent can be called a "nobleman (gentleman)"; Being good in neither are a "fool Man (Fool)"; Yet a fool man was better than a "small man (villain)" who prefers talent than virtue.

Now given the grades of talent and virtue of a group of people, you is supposed to rank them according to Sima Guang ' s th Eory.

Input Specification:

The

Each input file contains the one test case. Each case first gives 3 positive integers in a line:n (<=105), and the total number of people to be ranked; L (>=60), the lower bound of the qualified grades-that's, only the ones whose grades of talent and virtue are both Not below the line would be ranked; and H (<100), the higher line of qualification – that's, those with both grades no below this line is considered as The "sages", and would be ranked in non-increasing order according to their total grades. Those with talent grades below H but virtue grades not is cosidered as the "noblemen", and is also ranked in Non-increas ing order according to their total grades, but they is listed after the "Sages". Those with both grades below H, but with virtue not lower than talent is considered as the "Fool Men". They is ranked in the same and after the "noblemen". The rest of people whose grades both pass the L line is ranked after the ' Fool men '.

Then N lines follow, each gives the information of a person in the format:

`Id_number Virtue_grade Talent_grade`
Where Id_number is an 8-digit number, and both grades be integers in [0, 100]. All the numbers is separated by a space.

Output Specification:

The first line of output must give M (<=n) and the total number of people is actually ranked. Then M. lines follow, each gives the information of a person in the same format as the input, according to the ranking rule S. If there is a tie of the total grade, they must be ranked with respect to their virtue grades in non-increasing order. If There is still a tie and then the output in increasing order of their ID ' s.

Sample Input:
`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`

Submit Code

Word game, fortunately, the example of the topic is typical.

`1#include <cstdio>2#include <stack>3#include <cstring>4#include <iostream>5#include <stack>6#include <Set>7#include <map>8#include <algorithm>9 using namespacestd;Ten structrecord{ One     Charid[Ten]; A     intVg,tg,r; - record () { -R=0; the     } - }; - BOOLCMP (record A,record b) { -     if(a.r==B.R) { +         if(a.vg+a.tg==b.vg+B.TG) { -             if(a.vg==B.VG) { +                 returnstrcmp (A.id,b.id) <0; A             } at             returnA.vg>B.VG; -         } -         returna.vg+a.tg>b.vg+B.TG; -     } -     returnA.r>B.R; - } in //Virtue_grade Talent_grade - intMain () { to     //freopen ("D:\\input.txt", "R", stdin); +     intn,l,h; -scanf" %d%d%d",&n,&l,&h); theRecord *per=Newrecord[n+1]; *     intI,count=0, vg,tg,r=0; \$     Charid[Ten];Panax Notoginseng      for(i=0; i<n;i++){ -scanf"%s%d%d",&id,&vg,&TG); the         if(vg>=l&&tg>=l) {//It 's possible . +             if(vg>=h&&tg>=h) { Aper[count].r+=3; the             } +             Else if(VG&GT;=H&AMP;&AMP;TG&LT;H) {//nobleman -per[count].r+=2; \$             } \$             Else if(VG&LT;H&AMP;&AMP;TG&LT;H&AMP;&AMP;VG&GT;=TG) {//Fool Mans -per[count].r+=1; -             } the strcpy (per[count].id,id); -Per[count]. vg=VG;Wuyiper[count].tg=TG; thecount++; -         } Wu     } -Sort (per,per+count,cmp); Aboutprintf"%d\n", count); \$      for(i=0; i<count;i++){ -printf"%s%d%d\n", Per[i].id,per[i]. VG,PER[I].TG); -     } -     return 0; A}`

pat1062. Talent and Virtue (25)

Related Keywords:

### 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.