12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <iostream>
- #include <vector>
- #include <string>
- #include <algorithm>
- using namespace std;
- struct Grade {
- string Id;
- int Score;
- };
- bool compare(Grade a, Grade b) {
- if (a.Score > b.Score) {
- return true;
- } else if (a.Score < b.Score) {
- return false;
- }
- return a.Id < b.Id;
- }
- int main() {
- int N = 0, M = 0, G = 0;
- int *questions;
- while (cin >> N && N) {
- cin >> M >> G;
- questions = new int[M];
- vector<Grade> grade;
- // input question scoreIndex
- for (int i = 0; i < M; i++) {
- cin >> questions[i];
- }
- int answer;
- int total, scoreIndex;
- string id;
- for (int i = 0; i < N; i++) {
- answer = 0;
- total = 0, scoreIndex = 0;
- cin >> id;
- cin >> answer;
- for (int j = 0; j < answer; j++) {
- cin >> scoreIndex;
- total += questions[scoreIndex - 1];
- }
- if (total < G) {
- continue;
- }
- Grade tempGrade = {id, total};
- grade.push_back(tempGrade);
- }
- sort(grade.begin(), grade.end(), compare);
- cout << grade.size() << endl;
- for (int i = 0; i < (grade.size()); i++) {
- cout << grade.at(i).Id << " " << grade.at(i).Score << endl;
- }
- free(questions);
- grade.clear();
- }
- }
|