开始一个结构体做没过,后面分开就过了!!
#include<bits/stdc++.h>
using namespace std;
struct poin1
{
string str;
int cost;
}S[105];
struct poin2
{
string str;
int cost;
}M[105];
struct poin3
{
string str;
int cost;
}D[105];
bool cmp1(struct poin1 a,struct poin1 b)
{
return a.cost<b.cost;
}
bool cmp2(struct poin2 a,struct poin2 b)
{
return a.cost<b.cost;
}
bool cmp3(struct poin3 a,struct poin3 b)
{
return a.cost<b.cost;
}
int main()
{
int T;
cin>>T;
while(T--)
{
int a,b,c;
cin>>a>>b>>c;
for(int i=0;i<a;i++)
cin>>S[i].str>>S[i].cost;
for(int i=0;i<b;i++)
cin>>M[i].str>>M[i].cost;
for(int i=0;i<c;i++)
cin>>D[i].str>>D[i].cost;
sort(S,S+a,cmp1);
sort(M,M+b,cmp2);
sort(D,D+c,cmp3);
int sum;
sum=S[a/2].cost+M[b/2].cost+D[c/2].cost;
cout<<sum<<" "<<S[a/2].str<<" "<<M[b/2].str<<" "<<D[c/2].str<<"\n";
}
return 0;
}