#include <cstdio>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
using namespace std;
struct student{
int ge,gi,sum,id;
int adm[5];
}st[40100];
struct school{
int count;
vector<student> ad;
}sc[110];
vector<int>s[110];
int cmp(const student &a,const student &b){
if(a.sum==b.sum){
return a.ge>b.ge;
}
else
return a.sum>b.sum;
}
int cmp1(const student &a,const student &b){
return a.id<b.id;
}
int vit[40100];
int main()
{
//freopen("G://test.txt","r",stdin);
int n,m,k;
while(scanf("%d%d%d",&n,&m,&k)!=EOF){
memset(vit,0,sizeof(vit));
for(int i=0;i<m;++i){
scanf("%d",&sc[i].count);
}
for(int i=0;i<n;++i){
scanf("%d%d",&st[i].ge,&st[i].gi);
st[i].sum=st[i].ge+st[i].gi;
st[i].id=i;
for(int j=0;j<k;++j){
int temp;
scanf("%d",&temp);
st[i].adm[j]=temp;
}
}
sort(st,st+n,cmp);
for(int j=0;j<n;++j){
for(int i=0;i<k;i++){
if(sc[st[j].adm[i]].count>0){
sc[st[j].adm[i]].ad.push_back(st[j]);
sc[st[j].adm[i]].count--;
break;
}
else{
if(sc[st[j].adm[i]].ad.size()>0){
if(sc[st[j].adm[i]].ad[sc[st[j].adm[i]].ad.size()-1].sum==st[j].sum&&sc[st[j].adm[i]].ad[sc[st[j].adm[i]].ad.size()-1].ge==st[j].ge){
sc[st[j].adm[i]].ad.push_back(st[j]);
break;
}
}
}
}
}
for(int i=0;i<m;++i){
sort(sc[i].ad.begin(),sc[i].ad.end(),cmp1);
for(int j=0;j<sc[i].ad.size();++j){
if(j==0)
printf("%d",sc[i].ad[j].id);
else
printf(" %d",sc[i].ad[j].id);
}
printf("\n");
}
}
return 0;
}
PAT 1080Graduate Admission
最新推荐文章于 2022-10-07 16:37:59 发布