首页 > 其他 > 详细

1062 Talent and Virtue (25)

时间:2015-02-01 08:25:59      阅读:348      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!