-
Notifications
You must be signed in to change notification settings - Fork 2
/
A1080.cpp
74 lines (70 loc) · 1.72 KB
/
A1080.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
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 40000 + 10;
struct Student{
int id, Ge, Gi, sum, choice[10], rank;
//bool admit;
} stu[MAXN];
bool cmp(const Student &s1, const Student &s2){
if(s1.sum != s2.sum) return s1.sum > s2.sum;
else return s1.Ge > s2.Ge;
}
int num[110] = {0};
int cnt[110] = {0};
int pree[110] = {0};
int prei[110] = {0};
int preid[110] = {0};
int result[110][MAXN] = {0};
int N, M, K;
int main(){
scanf("%d%d%d", &N, &M, &K);
for(int i = 0; i < M; ++i){
scanf("%d", &num[i]);
}
for(int i = 0; i < N; ++i){
//stu[i].admit = false;
scanf("%d%d", &stu[i].Ge, &stu[i].Gi);
for(int j = 0; j < K; ++j){
scanf("%d", &stu[i].choice[j]);
}
stu[i].sum = stu[i].Ge + stu[i].Gi;
stu[i].id = i;
}
sort(stu, stu + N, cmp);
stu[0].rank = 1;
for(int i = 1; i < N; ++i){
if(stu[i].sum == stu[i-1].sum && stu[i].Ge == stu[i-1].Ge ){
stu[i].rank = stu[i-1].rank;
}else{
stu[i].rank = i + 1;
}
}
for(int i = 0; i < N; ++i){
for(int j = 0; j < K; ++j){
int cho = stu[i].choice[j];
//if(cnt[cho] < num[cho] || (cnt[cho] > 0 && stu[result[cho][cnt[cho]-1]].rank == stu[i].rank)){
if(cnt[cho] < num[cho] || (cnt[cho] > 0 && pree[cho] == stu[i].Ge && prei[cho] == stu[i].Gi)){
//if(cnt[cho] < num[cho] || (cnt[cho] > 0 && stu[preid[cho]].rank == stu[i].rank)){
result[cho][cnt[cho]] = stu[i].id;
pree[cho] = stu[i].Ge;
prei[cho] = stu[i].Gi;
preid[cho] = stu[i].id;
//stu[i].admit = true;
++cnt[cho];
break;
}
}
}
for(int i = 0; i < M; ++i){
if(cnt[i] > 0){
sort(&result[i][0], &result[i][cnt[i]]);
for(int j = 0; j < cnt[i]; ++j){
if(j != 0) printf(" ");
printf("%d", result[i][j]);
}
}
printf("\n");
}
return 0;
}