﻿PAT(B) 1015. 德才论 (25)-Ocrosoft

# PAT(B) 1015. 德才论 (25)

```14 60 80
10000001 64 90
10000002 90 60
10000011 85 80
10000003 85 80
10000004 80 85
10000005 82 77
10000006 83 76
10000007 90 78
10000008 75 79
10000009 59 90
10000010 88 45
10000012 80 100
10000013 90 99
10000014 66 60
```

```12
10000013 90 99
10000012 80 100
10000003 85 80
10000011 85 80
10000004 80 85
10000007 90 78
10000006 83 76
10000005 82 77
10000002 90 60
10000014 66 60
10000008 75 79
10000001 64 90
```
```#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define strend string::npos
#define ms(a) memset(a,0,sizeof(a))
#define rep(a,v,b) for(int a=v;a<b;a++)
#define repe(a,v,b) for(int a=v;a<=b;a++)
#define pre(a,v,b) for(int a=v;a>b;a--)
#define pree(a,v,b) for(int a=v;a>=b;a--)
#define lowbit(x) x&-x
typedef long long LL;
const LL LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const int MAXN = 27 + 10;
const int MOD = 1000000007;
int gcd(int a, int b)
{
if (!b)return a;
return gcd(b, a%b);
}
/*(◕‿‿◕)(◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕)*/
/*(◕‿‿◕) 签订契约,成为马猴烧酒吧 (◕‿‿◕)*/
/*(◕‿‿◕)(◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕)*/
using namespace std;
struct Student
{
int num;
int d;
int c;
bool operator < (const Student &other) const
{
if (d + c != other.d + other.c)
return d + c > other.d + other.c;
else
{
if (d != other.d)
return d > other.d;
else
return num < other.num;
}
}
};

int main()
{
int n, l, h, count = 0;
Student tmp;
vector<Student> v1, v2, v3, v4;
scanf("%d%d%d", &n, &l, &h);
int x, y, z;
for (int i = 0; i < n; i++)
{
scanf("%d%d%d", &x, &y, &z);
tmp.num = x;
tmp.d = y;
tmp.c = z;
if (y >= l && z >= l)
{
count++;
if (y >= h && z >= h)
{
v1.push_back(tmp);
}
else if (y >= h && z < h)
{
v2.push_back(tmp);
}
else if (y < h && z < h && y >= z)
{
v3.push_back(tmp);
}
else
{
v4.push_back(tmp);
}
}
}
sort(v1.begin(), v1.end());
sort(v2.begin(), v2.end());
sort(v3.begin(), v3.end());
sort(v4.begin(), v4.end());
cout << count << endl;
vector<Student>::iterator itr;
for (itr = v1.begin(); itr != v1.end(); ++itr)
printf("%d %d %d\n", itr->num, itr->d, itr->c);
for (itr = v2.begin(); itr != v2.end(); ++itr)
printf("%d %d %d\n", itr->num, itr->d, itr->c);
for (itr = v3.begin(); itr != v3.end(); ++itr)
printf("%d %d %d\n", itr->num, itr->d, itr->c);
for (itr = v4.begin(); itr != v4.end(); ++itr)
printf("%d %d %d\n", itr->num, itr->d, itr->c);
return 0;
}```