-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraduate_Admission.cpp
91 lines (88 loc) · 1.79 KB
/
Graduate_Admission.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
#include <algorithm>
#include <iostream>
struct student
{
int id;
int rank;
int ge, gi;
int choice[5];
};
student s[40010];
struct school
{
int rank;
int student[40000];
int count = 0;
};
school g[100];
int numbre[100];
bool cmp(student a, student b)
{
if (a.ge + a.gi == b.ge + b.gi)
{
return a.ge > b.ge;
}
return a.ge + a.gi > b.ge + b.gi;
}
int main()
{
int n, m, k;
std::cin >> n >> m >> k;
for (int i = 0; i < m; i++)
{
std::cin >> numbre[i];
}
for (int i = 0; i < n; i++)
{
std::cin >> s[i].ge >> s[i].gi;
for (int j = 0; j < k; j++)
{
std::cin >> s[i].choice[j];
}
s[i].id = i;
}
std::sort(s, s + n, cmp);
s[0].rank = 1;
for (int i = 1; i < n; i++)
{
if (s[i].ge == s[i - 1].ge && s[i].gi == s[i - 1].gi)
{
s[i].rank = s[i - 1].rank;
}
else
{
s[i].rank = i + 1;
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < k; j++)
{
int temp = s[i].choice[j];
if (numbre[temp] > g[temp].count || s[i].rank == g[temp].rank)
{
g[temp].student[g[temp].count] = s[i].id;
g[temp].count++;
g[temp].rank = s[i].rank;
break;
}
}
}
for (int i = 0; i < m; i++)
{
std::sort(g[i].student, g[i].student + g[i].count);
for (int j = 0; j < g[i].count - 1; j++)
{
std::cout << g[i].student[j] << " ";
}
if (g[i].count == 0)
{
std::cout << std::endl;
}
else
{
std::cout << g[i].student[g[i].count - 1] << std::endl;
}
}
return 0;
}