题目传送门
/*
水题:找排序找中间的价格,若有两个,选价格大的;
写的是有点搓:)
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
struct S
{
char name[];
int p;
}s[];
struct M
{
char name[];
int p;
}m[];
struct D
{
char name[];
int p;
}d[];
bool cmp_s(S x, S y)
{
return x.p < y.p;
}
bool cmp_m(M x, M y)
{
return x.p < y.p;
}
bool cmp_d(D x, D y)
{
return x.p < y.p;
}
int main(void) //ZOJ 3875 Lunch Time
{
//freopen ("G.in", "r", stdin);
int t;
scanf ("%d", &t);
while (t--)
{
int a, b, c;
int tot = , s_id, m_id, d_id;
scanf ("%d%d%d", &a, &b, &c);
for (int i=; i<=a; ++i)
{
scanf ("%s%d", &s[i].name, &s[i].p);
}
sort (s+, s++a, cmp_s);
for (int i=; i<=b; ++i)
{
scanf ("%s%d", &m[i].name, &m[i].p);
}
sort (m+, m++b, cmp_m);
for (int i=; i<=c; ++i)
{
scanf ("%s%d", &d[i].name, &d[i].p);
}
sort (d+, d++c, cmp_d);
if (a & )
{
tot += s[(a+)/].p; s_id = (a+) / ;
}
else
{
int l = a / ; int r = l + ;
if (s[l].p < s[r].p)
{
tot += s[r].p; s_id = r;
}
else
{
tot += s[l].p; s_id = l;
}
}
if (b & )
{
tot += m[(b+)/].p; m_id = (b+) / ;
}
else
{
int l = b / ; int r = l + ;
if (m[l].p < m[r].p)
{
tot += m[r].p; m_id = r;
}
else
{
tot += m[l].p; m_id = l;
}
}
if (c & )
{
tot += d[(c+)/].p; d_id = (c+) / ;
}
else
{
int l = c / ; int r = l + ;
if (d[l].p < d[r].p)
{
tot += d[r].p; d_id = r;
}
else
{
tot += d[l].p; d_id = l;
}
}
printf ("%d %s %s %s\n", tot, s[s_id].name, m[m_id].name, d[d_id].name);
}
return ;
}
/*
15 Fresh_Cucumber Fried_Vermicelli Steamed_Stuffed_Bun
108 West_Lake_Water_Shield_Soup DongPo's_Braised_Pork DongPo's_Crisp
*/