158 vector<tuple<string, string, unsigned short>>
vec(n);
159 for(
int i = 0; i < n; i++) {
163 cin >> name >>
id >> grade;
164 vec[i] = make_tuple(name,
id, grade);
166 sort(
vec.begin(),
vec.end(), [](
const tuple<string, string, unsigned short> &a,
const tuple<string, string, unsigned short> &b) ->
bool {
167 const auto &[a_name, a_id, a_grade] = a;
168 const auto &[b_name, b_id, b_grade] = b;
169 return a_grade < b_grade;
171 auto [highest_name, highest_id, highest_grade] =
vec.back();
172 auto [lowest_name, lowest_id, lowest_grade] =
vec.front();
173 cout << highest_name <<
' ' << highest_id << endl
174 << lowest_name <<
' ' << lowest_id;