-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8979.cpp
60 lines (55 loc) · 820 Bytes
/
8979.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
56
57
58
59
60
// 8979. 올림픽
// 2019.05.21
// 구현
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
class medal
{
public:
int total;
int gold;
int silver;
int bronze;
};
int n, k;
vector<medal> v;
bool comp(medal a, medal b)
{
if (a.gold != b.gold) // 금
{
return a.gold > b.gold;
}
else if (a.silver != b.silver) // 은
{
return a.silver > b.silver;
}
else if (a.bronze != b.bronze) // 동
{
return a.bronze > b.bronze;
}
else // 총개수
{
return a.total == k;
}
}
int main()
{
medal medal;
cin >> n >> k;
for (int i = 0; i<n; i++)
{
cin >> medal.total >> medal.gold >> medal.silver >> medal.bronze;
v.push_back(medal);
}
sort(v.begin(), v.end(), comp);
for (int i = 0; i<n; i++)
{
if (v[i].total == k)
{
cout << i + 1 << endl;
}
}
return 0;
}