#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAXN=40010;
const int MAXM=101;
struct stu{
int id;
int ge;
int gi;
int gei;
int a[5];
int rank;
stu(){
id=-1;
ge=0;
gi=0;
gei=0;
a[5]={-1};
rank=-1;
}
}student[MAXN];
struct sch{
int quota;
vector<int> b;
int flag;
sch(){
quota=0;
flag=0;
}
}school[MAXM];
bool cmp(stu a,stu b){
if(a.gei!=b.gei) return a.gei>b.gei;
else if(a.ge!=b.ge) return a.ge>b.ge;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int n,m,k;
cin>>n>>m>>k;
for(int i=0;i<m;i++){
cin>>school[i].quota;
}
for(int i=0;i<n;i++){
student[i].id=i;
cin>>student[i].ge>>student[i].gi;
for(int j=0;j<k;j++){
cin>>student[i].a[j];
}
student[i].gei=(student[i].ge+student[i].gi)/2;
}
sort(student,student+n,cmp);
student[0].rank=1;
for(int i=1;i<n;i++){
if(student[i].gei==student[i-1].gei&&student[i].ge==student[i-1].ge){
student[i].rank=student[i-1].rank;
}else if((student[i].gei==student[i-1].gei&&student[i].ge<student[i-1].ge)||(student[i].gei<student[i-1].gei)){
student[i].rank=i+1;
}
}
for(int i=0;i<n;i++){
for(int j=0;j<k;j++){
int this_school=student[i].a[j];
int size=school[this_school].b.size();
if(school[student[i].a[j]].quota>0||(student[i].rank==student[school[this_school].b[size-1]].rank)){
school[student[i].a[j]].b.push_back(student[i].id);
school[student[i].a[j]].quota--;school[student[i].a[j]].flag=1;
break;
}
}
}
for(int i=0;i<m;i++){
if(school[i].b.size()>0){
sort(school[i].b.begin(),school[i].b.end());
for(int j=0;j<school[i].b.size();j++){
if(j==0) cout<<school[i].b[j];
else cout<<' '<<school[i].b[j];
}
}
cout<<endl;
}
return 0;
}
得了22分就很尴尬了,一个超时两个错误,唉,debug吧