-
Notifications
You must be signed in to change notification settings - Fork 814
/
Copy path1080. Graduate Admission (30) .cpp
51 lines (51 loc) · 1.42 KB
/
1080. Graduate Admission (30) .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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct peo{
int id, ge, gi, fin;
vector<int> choice;
};
bool cmp(peo& a, peo& b) {
if (a.fin != b.fin) return a.fin > b.fin;
return a.ge > b.ge;
}
bool cmp2(peo& a, peo& b) {
return a.id < b.id;
}
int main(){
int n, m, k, quota[110], cnt[110] = {0};
scanf("%d%d%d", &n, &m, &k);
vector<peo> stu(n), sch[110];
for(int i = 0; i < m; i++)
scanf("%d","a[i]);
for(int i = 0; i < n; i++) {
scanf("%d%d", &stu[i].ge, &stu[i].gi);
stu[i].id = i;
stu[i].fin = stu[i].ge + stu[i].gi;
stu[i].choice.resize(k);
for(int j = 0; j < k; j++)
scanf("%d", &stu[i].choice[j]);
}
sort(stu.begin(), stu.end(), cmp);
for(int i = 0; i < n; i++) {
for(int j = 0; j < k; j++) {
int schid = stu[i].choice[j];
int lastindex = cnt[schid] - 1;
if(cnt[schid] < quota[schid] || (stu[i].fin == sch[schid][lastindex].fin) && stu[i].ge == sch[schid][lastindex].ge) {
sch[schid].push_back(stu[i]);
cnt[schid]++;
break;
}
}
}
for(int i = 0; i < m; i++) {
sort(sch[i].begin(), sch[i].end(), cmp2);
for(int j = 0; j < cnt[i]; j++) {
if(j != 0) printf(" ");
printf("%d", sch[i][j].id);
}
printf("\n");
}
return 0;
}