-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10825.cpp
More file actions
68 lines (65 loc) · 1.1 KB
/
10825.cpp
File metadata and controls
68 lines (65 loc) · 1.1 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
// 10825. 국영수
// 2019.05.22
// 정렬
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
// 학생 구조체 과목의 점수와 이름 저장
struct Student
{
public:
string name;
int korean;
int english;
int math;
Student(string s, int a, int b, int c) :name(s), korean(a), english(b), math(c) {}
Student() {}
};
// 주어진 조건대로 정렬하는 compare 함수
bool compare(Student& a, Student& b)
{
if (a.korean > b.korean)
{
return true;
}
else if (a.korean == b.korean)
{
if (a.english < b.english)
{
return true;
}
else if (a.english == b.english)
{
if (a.math > b.math)
{
return true;
}
else if (a.math == b.math)
{
return a.name < b.name;
}
}
}
return false;
}
int main()
{
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<Student> v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i].name >> v[i].korean >> v[i].english >> v[i].math;
}
// 조건에 따라 정렬
sort(v.begin(), v.end(), compare);
// 결과 출력
for (int i = 0; i < n; i++)
{
cout << v[i].name << "\n";
}
return 0;
}