-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPDD1.cpp
52 lines (47 loc) · 884 Bytes
/
PDD1.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
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
int main()
{
vector<int> arr;
int N = 0;
{
string input;
cin >> input;
istringstream ss(input);
string first, second;
std::getline(ss, first, ';');
std::getline(ss, second);
istringstream is(first);
for (string token; std::getline(is, token, ',');)
{
arr.push_back(std::stoi(token));
}
N = std::stoi(second);
}
// io done
auto compare = [](int a, int b) -> bool
{
if (!(a & 1))
{
if (!(b & 1))
return (a > b);
else
return true;
}
else
{
if (!(b & 1))
return false;
else
return (a > b);
}
};
std::sort(arr.begin(), arr.end(), compare);
for (int i = 0; i < N-1; ++i)
cout << arr[i] << ',';
cout << arr[N-1];
return 0;
}