| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 
 | #include <cstdio>#include <cstring>
 #include <cstdlib>
 #include <algorithm>
 #include <iostream>
 using namespace std;
 
 struct Node{
 int date;
 int name[105];
 };
 
 Node node[3][105];
 
 bool cmp(Node a, Node b)
 {
 return a.date < b.date;
 }
 
 int main()
 {
 int T, n, a, b, c;
 scanf("%d", &T);
 while(T--){
 scanf("%d%d%d", &a, &b, &c);
 for(int i = 0; i < a; i++)
 scanf("%s%d", node[0][i].name, &node[0][i].date);
 for(int i = 0; i < b; i++)
 scanf("%s%d", node[1][i].name, &node[1][i].date);
 for(int i = 0; i < c; i++)
 scanf("%s%d", node[2][i].name, &node[2][i].date);
 sort(node[0], node[0] + a, cmp);
 sort(node[1], node[1] + b, cmp);
 sort(node[2], node[2] + c, cmp);
 int ans = 0;
 ans += node[0][a / 2].date + node[1][b / 2].date + node[2][c / 2].date;
 printf("%d %s %s %s\n", ans, node[0][a / 2].name, node[1][b / 2].name, node[2][c / 2].name);
 }
 return 0;
 }
 
 |