PAT 乙级 1015/甲级 1062 德才论
作者:
自由基
,
2021-08-06 20:38:43
,
所有人可见
,
阅读 261
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
const int N = 100010;
struct Student
{
char id[10];
int de,cai,sum;
int flag; // 类别
}stu[N];
bool cmp( Student a, Student b ) {
if ( a.flag != b.flag ) return a.flag < b.flag;
else if ( a.sum != b.sum ) return a.sum > b.sum;
else if ( a.de != b.de ) return a.de > b.de;
else return strcmp(a.id, b.id ) < 0;
}
int main( ){
int n,l,h;
cin >> n >> l >> h;
int m = n; // m为及格人数
for ( int i =0; i < n; i++ ) {
cin >> stu[i].id >> stu[i].de >> stu[i].cai;
stu[i].sum = stu[i].de + stu[i].cai;
if ( stu[i].de < l || stu[i].cai < l ) {
stu[i].flag = 5;
m--;
}
else if ( stu[i].de >= h && stu[i].cai >= h ) stu[i].flag = 1;
else if ( stu[i].de >= h && stu[i].cai < h ) stu[i].flag = 2;
else if ( stu[i].de >= stu[i].cai ) stu[i].flag = 3;
else stu[i].flag = 4;
}
sort( stu, stu + n, cmp);
cout << m << endl;
for ( int i =0; i < m; i++ ) {
cout << stu[i].id << " " << stu[i].de << " " << stu[i].cai << endl;
}
return 0;
}