-
Notifications
You must be signed in to change notification settings - Fork 0
/
boj10825.cpp
55 lines (42 loc) · 1.11 KB
/
boj10825.cpp
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
49
50
51
52
53
54
55
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Student
{
string name;
int kor, eng, mat;
public:
Student(string name, int kor, int eng, int mat) : name(name), kor(kor), eng(eng), mat(mat) {}
bool operator<(Student& student)
{
if (this->kor == student.kor && this->eng == student.eng && this->mat == student.mat)
return this->name < student.name;
else if (this->kor == student.kor && this->eng == student.eng)
return this->mat > student.mat;
else if (this->kor == student.kor)
return this->eng < student.eng;
else
return this->kor > student.kor;
}
void PrintName()
{
cout << name << '\n';
}
};
int n, kor, eng, mat;
string name;
vector<Student> students;
int main()
{
cin >> n;
for (int i = 0; i < n; i++) {
cin >> name >> kor >> eng >> mat;
students.push_back(Student(name, kor, eng, mat));
}
sort(students.begin(), students.end());
for (int i = 0; i < n; i++)
students[i].PrintName();
return 0;
}