#include <bits/stdc++.h>
using namespace std;
struct student{
int id;
float Ge;
float Gi;
float final;
int choice[5];
int rank;
};
struct school{
int capacity;
vector<student>accept;
}sch[101];
bool cmp(student a,student b){
if(a.final!=b.final)
return a.final>b.final;
else
return a.Ge>b.Ge;
}
bool cmp1(student a,student b){
return a.id<b.id;
}
int main(){
int n,m,k;cin>>n>>m>>k;
for(int i=0;i<m;i++)
cin>>sch[i].capacity;
vector<student>v;
for(int i=0;i<n;i++){
student temp;
cin>>temp.Ge>>temp.Gi;
temp.id=i;
temp.final=temp.Gi+temp.Ge;
for(int j=0;j<k;j++)
cin>>temp.choice[j];
v.push_back(temp);
}
sort(v.begin(),v.end(),cmp);
int rank=1;student pre=v[0];
v[0].rank=rank;
for(int i=1;i<=v.size();i++){
if(v[i-1].final==pre.final&&v[i-1].Ge==pre.Ge)
v[i-1].rank=rank;
else{
rank=i;
pre=v[i-1];
v[i-1].rank=i;
}
}
for(int i=0;i<v.size();i++){
for(int j=0;j<k;j++){
int schNum=v[i].choice[j];
if(sch[schNum].capacity>0){
sch[schNum].accept.push_back(v[i]);
sch[schNum].capacity--;
break;
}
else{
if(v[i].rank==sch[schNum].accept[sch[schNum].accept.size()-1].rank){
sch[schNum].accept.push_back(v[i]);
break;
}
}
}
}
for(int i=0;i<m;i++){
vector<student>temp(sch[i].accept);
sort(temp.begin(),temp.end(),cmp1);
if(temp.size()==0)
cout<<endl;
else{
for(int j=0;j<temp.size()-1;j++)
cout<<temp[j].id<<" ";
cout<<temp[temp.size()-1].id<<endl;
}
}
}
|