forked from jaimemin/programmers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path[PCCE 기출문제] 10번.cpp
64 lines (59 loc) · 1.27 KB
/
[PCCE 기출문제] 10번.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
61
62
63
64
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<int>> solution(vector<vector<int>> data, string ext, int val_ext, string sort_by) {
vector<vector<int>> answer;
for (vector<int> d : data)
{
if (ext == "code")
{
if (d[0] >= val_ext)
{
continue;
}
}
else if (ext == "date")
{
if (d[1] >= val_ext)
{
continue;
}
}
else if (ext == "maximum")
{
if (d[2] >= val_ext)
{
continue;
}
}
else
{
if (d[3] >= val_ext)
{
continue;
}
}
answer.push_back(d);
}
sort(answer.begin(), answer.end(), [&sort_by]( const vector<int>& a, const vector<int>& b)
{
if (sort_by == "code")
{
return a[0] < b[0];
}
else if (sort_by == "date")
{
return a[1] < b[1];
}
else if (sort_by == "maximum")
{
return a[2] < b[2];
}
else
{
return a[3] < b[3];
}
});
return answer;
}