-
Notifications
You must be signed in to change notification settings - Fork 0
/
1062.cpp
98 lines (88 loc) · 1.53 KB
/
1062.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;
#define SAGES 0
#define NOBLEMEN 1
#define FOOLMEN 2
#define SMALLMEN 3
#define NOTPASS 4
typedef struct node
{
int id;
int virtue;
int talent;
int total;
int kind;
}node;
node records[100010];
bool less_than_node(const node &A, const node &B)
{
if (A.kind != B.kind)
{
return A.kind < B.kind;
}
else
{
if (A.total != B.total)
{
return A.total > B.total;
}
else
{
if (A.virtue != B.virtue)
{
return A.virtue > B.virtue;
}
else
{
return A.id < B.id;
}
}
}
}
int main()
{
int N, L, H;
int passNum = 0;
scanf("%d %d %d", &N, &L, &H);
for (int i = 0; i != N; ++i)
{
scanf("%d %d %d", &records[i].id, &records[i].virtue, &records[i].talent);
records[i].total = records[i].virtue + records[i].talent;
if (records[i].virtue < L || records[i].talent < L)
{
records[i].kind = NOTPASS;
continue;
}
++passNum;
if (records[i].virtue >= H && records[i].talent >= H)
{
records[i].kind = SAGES;
continue;
}
if (records[i].virtue >= H && records[i].talent < H)
{
records[i].kind = NOBLEMEN;
continue;
}
if (records[i].virtue >= records[i].talent)
{
records[i].kind = FOOLMEN;
continue;
}
records[i].kind = SMALLMEN;
}
printf("%d\n", passNum);
if (0 == passNum)
{
return 0;
}
sort(records, records+N, less_than_node);
for (int i = 0; i != passNum; ++i)
{
printf("%08d %d %d\n", records[i].id, records[i].virtue, records[i].talent);
}
system("pause");
return 0;
}