您的位置:首页 > 产品设计 > UI/UE

1062 Talent and Virtue (25)

2015-02-01 08:11 260 查看
/*

L (>=60), the lower bound of the qualified grades --
that is, only the ones whose grades of talent and virtue are both not below
this line will be ranked;

and H (<100), the higher line of qualification

,those with both grades not below this line are considered as the "sages",
and will be ranked in non-increasing order according to their total grades.

Those with talent grades below H but virtue grades not are cosidered as
the "noblemen", and are also ranked in non-increasing order according to
their total grades, but they are listed after the "sages".

Those with both grades below H,
but with virtue not lower than talent are considered as the "fool men".
They are ranked in the same way but after the "noblemen".

The rest of people whose grades both pass the L line are ranked
after the "fool men".

*/

#include <string.h>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;

struct peo
{
char num[9];
int all,t,v;
int id;
};

bool cmp(peo a,peo b)
{
if(a.id==b.id)
{
if(a.all == b.all)
{
if(a.v == b.v )
return (strcmp(a.num,b.num)<0);
else return a.v > b.v;
}
else return a.all > b.all;
}
else return a.id<b.id;

}

int main()
{

int i,n,low,high,v,t;
char num[9];
while(scanf("%d%d%d",&n,&low,&high)!=EOF)
{

vector<peo> VP;
for(i=0;i<n;i++)
{
getchar();
scanf("%s %d %d",num,&v,&t);
if(t>=low && v>=low)
{
peo pp;
strcpy(pp.num,num);
pp.v=v;
pp.t=t;
pp.all=v+t;
if(v>=high && t>=high)
pp.id=1;
else if(v>= high && t<high)
pp.id=2;
else if(v< high && t< high && v>=t)
pp.id=3;
else
pp.id=4;

VP.push_back(pp);
}
}

sort(VP.begin(),VP.end(),cmp);
printf("%d\n",VP.size());
for(i=0;i<VP.size();i++)
printf("%s %d %d\n",VP[i].num,VP[i].v,VP[i].t);

}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: