#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;
typedef struct Stu {
int id;
int ge;
int gi;
int gf;
int sch[6];
} Stu;
bool cmp(Stu a, Stu b);
bool equal(Stu a, Stu b);
bool cmp2(int a, int b);
int main() {
int n, m, k;
cin >> n >> m >> k;
int *quota = new int[m];
vector<Stu> stuList;
int i, j;
for (i = 0; i < m; i++)
cin >> quota[i];
for (i = 0; i < n; i++) {
Stu s;
cin >> s.ge >> s.gi;
for (j = 0; j < k; j++) {
cin >> s.sch[j];
}
s.gf = s.ge + s.gi;
s.id = i;
stuList.push_back(s);
}
vector<Stu> stuList2(stuList);
sort(stuList.begin(), stuList.end(), cmp);
vector<int> out[100];
for (i = 0; i < n; i++) {
for (j = 0; j < k; j++) {
int school = stuList[i].sch[j];
if (quota[school] > 0) {
quota[school]--;
out[school].push_back(stuList[i].id);
break;
} else if (quota[school] == 0) {
if (out[school].size() && equal(stuList2[out[school].back()], stuList[i])) {
out[school].push_back(stuList[i].id);
break;
}
}
}
}
for (i = 0; i < m; i++) {
sort(out[i].begin(), out[i].end(), cmp2);
for (j = 0; j < out[i].size(); j++) {
cout << out[i][j] << (j == out[i].size()-1 ? "" : " ");
}
cout << endl;
}
return 0;
}
bool cmp(Stu a, Stu b) {
if(a.gf > b.gf) return true;
else if (a.gf == b.gf && a.ge > b.ge) return true;
return false;
}
bool equal(Stu a, Stu b) {
if (a.gf == b.gf && a.ge == b.ge) return true;
return false;
}
bool cmp2(int a, int b) {
if (a < b) return true;
return false;
}
【PAT甲级】1080 Graduate Admission (30 分)
最新推荐文章于 2019-12-23 13:23:41 发布