1 2 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 41 42 43 44 45 46 47 48
| #include <iostream> using namespace std;
struct student { string name; string major; };
int main() { int n; cin >> n; student s, male_min, female_max; int score, male_score_min = 101, female_score_max = -1; string gender; for (int i = 0; i < n; i++) { cin >> s.name >> gender >> s.major >> score; if (gender == "M") { if (score < male_score_min) { male_min = s; male_score_min = score; } } else { if (score > female_score_max) { female_max = s; female_score_max = score; } } }
if (female_score_max != -1) { cout << female_max.name << " " << female_max.major << endl; } else { cout << "Absent" << endl; } if (male_score_min != 101) { cout << male_min.name << " " << male_min.major << endl; } else { cout << "Absent" << endl; } if (female_score_max != -1 && male_score_min != 101) { cout << female_score_max - male_score_min << endl; } else { cout << "NA" << endl; }
return 0; }
|