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; }
相关文章推荐
- PAT_B_1015. 德才论 (25) or PAT_A_1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- PAT (Advanced Level) Practise 1062 Talent and Virtue (25)
- PAT - 甲级 - 1062. Talent and Virtue (25)(排序)
- PAT 1062. Talent and Virtue (25)
- 1015. 德才论 (25) PAT乙级&1062. Talent and Virtue (25)PAT甲级
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- pat 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25) 大量输入输出 scanf printf会比cin cout 省很多时间
- 1062. Talent and Virtue (25)
- 【PAT】【Advanced Level】1062. Talent and Virtue (25)