*原题链接*
AC代码:
#include <iostream>
#include<stdio.h>
#include <algorithm>
#include<queue>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
using namespace std;
struct student {
string name;
int sum;
};
bool cmp(student a1, student a2) {
if (a1.sum != a2.sum)
{
return a1.sum > a2.sum;
}
else
{
return a1.name < a2.name;
}
}
struct student stu[1005];
int value[15];
int main() {
int n;
while (scanf("%d", &n) != EOF) {
if (!n)break;
int m, g;
scanf("%d %d", &m, &g);
for (int i = 0; i < m; i++)
{
scanf("%d", &value[i]);
}
for (int i = 0; i < n; i++) {
int ac_num;
cin >> stu[i].name;
scanf("%d", &ac_num);
stu[i].sum = 0;
for (int j = 0; j < ac_num; j++) {
int temp;
scanf("%d", &temp);
stu[i].sum += value[temp - 1];
}
}
sort(stu, stu + n, cmp);
int num = 0;
for (int i = 0; i < n; i++)
{
if (stu[i].sum < g)break;
num++;
}
cout << num << '\n';
for (int i = 0; i < num; i++)
{
cout << stu[i].name << ' ' << stu[i].sum << '\n';
}
}
return 0;
}