#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
struct Student {
string name;
string sex;
int age;
int score;
friend bool operator <(const Student &a, const Student &b) {
if (a.score != b.score)
return a.score > b.score;
else if (a.sex != b.sex)
return a.sex < b.sex;
else
return a.name > b.name;
}
};
int main() {
int n;
string name;
string sex;
int age;
int score;
cin >> n;
priority_queue<Student> stu;
Student s;
for (int i = 0; i < n; i++) {
cin >> name >> sex >> age >> score;
s = {name, sex, age, score};
stu.push(s);
}
for (int i = 0; i < n; i++) {
Student t;
t = stu.top();
cout << t.name<<" " << t.sex<<" " << t.age <<" "<< t.score<<endl;
stu.pop();
}
return 0;
}
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
struct Student {
string name;
string sex;
int age;
int score;
friend bool operator <(const Student &a, const Student &b) {
if (a.score != b.score)
return a.score > b.score;
else if (a.sex != b.sex)
return a.sex < b.sex;
else
return a.name > b.name;
}
};
int main() {
int n;
string name;
string sex;
int age;
int score;
cin >> n;
priority_queue<Student> stu;
Student s;
for (int i = 0; i < n; i++) {
cin >> name >> sex >> age >> score;
s = {name, sex, age, score};
stu.push(s);
}
for (int i = 0; i < n; i++) {
Student t;
t = stu.top();
cout << t.name<<" " << t.sex<<" " << t.age <<" "<< t.score<<endl;
stu.pop();
}
return 0;
}