码迷,mamicode.com
首页 > 其他好文 > 详细

1062 Talent and Virtue (25)

时间:2015-02-01 08:28:31      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

  1 /*
  2 
  3 
  4 L (>=60), the lower bound of the qualified grades -- 
  5 that is, only the ones whose grades of talent and virtue are both not below
  6 this line will be ranked; 
  7 
  8 and H (<100), the higher line of qualification
  9 
 10 
 11 ,those with both grades not below this line are considered as the "sages",
 12 and will be ranked in non-increasing order according to their total grades. 
 13 
 14 Those with talent grades below H but virtue grades not are cosidered as 
 15 the "noblemen", and are also ranked in non-increasing order according to 
 16 their total grades, but they are listed after the "sages". 
 17 
 18 
 19 Those with both grades below H, 
 20 but with virtue not lower than talent are considered as the "fool men".
 21 They are ranked in the same way but after the "noblemen". 
 22 
 23 
 24 The rest of people whose grades both pass the L line are ranked 
 25 after the "fool men".
 26 
 27 
 28 
 29 */
 30 
 31 #include <string.h>
 32 #include <map>
 33 #include <iomanip>
 34 #include <algorithm>
 35 #include <vector>
 36 #include <stdio.h>
 37 using namespace std;
 38 
 39 struct peo
 40 {
 41     char num[9];
 42     int all,t,v;
 43     int id;
 44 };
 45 
 46 int high;
 47 
 48 bool cmp(peo a,peo b)
 49 {
 50     if(a.id==b.id)
 51     {
 52         if(a.all == b.all)
 53         {
 54             if(a.v == b.v )
 55                 return (strcmp(a.num,b.num)<0);
 56             else return a.v > b.v;
 57         }
 58         else return a.all > b.all;
 59     }
 60     else return a.id<b.id;
 61 
 62 }
 63 
 64 int main()
 65 {
 66 
 67     int i,j,n,low,v,t;
 68     char num[9];
 69     while(scanf("%d%d%d",&n,&low,&high)!=EOF)
 70     {
 71 
 72         vector<peo> VP;
 73         for(i=0;i<n;i++)
 74         {
 75             getchar();
 76             scanf("%s %d %d",num,&v,&t);
 77             if(t>=low && v>=low)
 78             {
 79                 peo pp;
 80                 strcpy(pp.num,num);
 81                 pp.v=v;
 82                 pp.t=t;
 83                 pp.all=v+t;
 84                 if(v>=high && t>=high)
 85                     pp.id=1;
 86                 else if(v>= high && t<high)
 87                     pp.id=2;    
 88                 else if(v< high && t< high && v>=t)
 89                     pp.id=3;
 90                 else 
 91                     pp.id=4;
 92 
 93                 VP.push_back(pp);
 94             }
 95         }
 96 
 97         sort(VP.begin(),VP.end(),cmp);
 98 
 99 
100         printf("%d\n",VP.size());
101         
102 
103         for(i=0;i<VP.size();i++)
104             printf("%s %d %d\n",VP[i].num,VP[i].v,VP[i].t);
105         
106 
107 
108     }
109 
110 
111 
112 
113     return 0;
114 }

 

1062 Talent and Virtue (25)

标签:

原文地址:http://www.cnblogs.com/xiaoyesoso/p/4265171.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!