思路:水题...
#include<bits/stdc++.h>
using namespace std;
int T;
struct node
{
char name[1005];
int w;
}nodes[3][105];
bool cmp(node a,node b)
{
return a.w<b.w;
}
int main()
{
scanf("%d",&T);
while (T--)
{
int S,M,D;
scanf("%d%d%d",&S,&M,&D);
for (int i = 0;i<S;i++)
scanf("%s%d",nodes[0][i].name,&nodes[0][i].w);
for (int i = 0;i<M;i++)
scanf("%s%d",nodes[1][i].name,&nodes[1][i].w);
for (int i = 0;i<D;i++)
scanf("%s%d",nodes[2][i].name,&nodes[2][i].w);
sort(nodes[0],nodes[0]+S,cmp);
sort(nodes[1],nodes[1]+M,cmp);
sort(nodes[2],nodes[2]+D,cmp);
int ans=nodes[0][S/2].w+nodes[1][M/2].w+nodes[2][D/2].w;
printf("%d %s %s %s\n",ans,nodes[0][S/2].name,nodes[1][M/2].name,nodes[2][D/2].name);
}
return 0;
}
Description
The 999th Zhejiang Provincial Collegiate Programming Contest will be held in Marjar University. The canteen of Marjar University is making preparations for this grand competition. The canteen provides a lunch set of three types: appetizer, main course and
dessert. Each type has several dishes with different prices for choosing.
Edward is the headmaster of Marjar University. One day, to inspect the quality of dishes, he go to the canteen and decides to choose amedian set for his lunch. That means he must choose one dish from each of appetizers, main courses and
desserts. Each chosen dish should at the median price among all dishes of the same type.
For example, if there are five dessert dishes selling at the price of 2, 3, 5, 10, 30, Edward should choose the dish with price 5 as his dessert since its price is located at the median place of the dessert type. If the number of dishes of a type is even,
Edward will choose the dish which is more expensive among the two medians.
You are given the list of all dishes, please write a program to help Edward decide which dishes he should choose.
Output
For each test case, output the total price of the median set, together with the names of appetizer, main course and dessert, separated by a single space.
Sample Output
15 Fresh_Cucumber Fried_Vermicelli Steamed_Stuffed_Bun
108 West_Lake_Water_Shield_Soup DongPo's_Braised_Pork DongPo's_Crisp