#include <iostream> using namespace std; const int N = 1000; typedef struct Student { char id[21]; int m = 0, sum = 0; } Student; int cmp(const void* a, const void* b) { Student* sa = (Student*)a; Student* sb = (Student*)b; if (sa->sum != sb->sum) return sb->sum - sa->sum; else return sa->id - sb->id; } Student s[1000]; int n, m, g; int score[11]; int main() { while (cin >> n >> m >> g) { for (int i = 1 ; i <= m; i++) cin >> score[i]; for (int i = 0 ; i < n ; i++) { cin >> s[i].id >> s[i].m; for (int j = 1 ; j <= s[i].m ; j++) { int k; cin >> k; s[i].sum += score[k]; } } qsort(s, n, sizeof(Student), cmp); int cnt = 0; for (int i = 0 ; i < n && s[i].sum >= g; i++) cnt++; cout << cnt << endl; for (int i = 0 ; i < cnt; i++) cout << s[i].id << " " << s[i].sum << endl; } return 0; } // 64 位输出请用 printf("%lld")