1062 Talent and Virtue (25)

  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 }
时间: 2024-12-19 11:58:18

1062 Talent and Virtue (25)的相关文章

1062. Talent and Virtue (25)【排序】——PAT (Advanced Level) Practise

题目信息 1062. Talent and Virtue (25) 时间限制200 ms 内存限制65536 kB 代码长度限制16000 B About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outstanding i

PAT 1062. Talent and Virtue (25)

1062. Talent and Virtue (25) About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outstanding in both talent and virtue must be a "sage(圣人

PAT (Advanced Level) 1062. Talent and Virtue (25)

简单排序.题意较长. #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<string> #include<stack> #include<map> #include<algorithm> using namespace std; struct X { int id;

pat1062. Talent and Virtue (25)

1062. Talent and Virtue (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Li About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a

PAT 1062 Talent and Virtue[难]

1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outstanding in both talent and virtue must be a "sage(圣

PAT-B 1015. 德才论(同PAT 1062. Talent and Virtue)

1. 在排序的过程中,注意边界的处理(小于.小于等于) 2. 对于B-level,这题是比較麻烦一些了. 源代码: #include <cstdio> #include <vector> #include <algorithm> using namespace std; struct People { int m_id; int m_virtue; int m_talent; People(int id, int virtue, int talent): m_id(id

PAT 1062 Talent and Virtue

#include <cstdio> #include <cstdlib> #include <cstring> #include <vector> #include <algorithm> using namespace std; class Man { public: char id[10]; int talent; int virtue; }; bool mycmp(const Man& a, const Man& b) {

1062. Talent and Virtue

About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outstanding in both talent and virtue must be a "sage(圣人)"; being less excellent

pat(A) 1062. Talent and Virtue(结构体排序)

代码: #include<cstdio> #include<cstring> #include<algorithm> #define N 100005 using namespace std; struct Node { int num; int v; int t; void Set(int x,int y,int z) { num=x; v=y; t=z; } }; int cmp(Node a,Node b) { if((a.t+a.v==b.v+b.t)&