-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwo Sets.cpp
More file actions
57 lines (53 loc) · 1.01 KB
/
Two Sets.cpp
File metadata and controls
57 lines (53 loc) · 1.01 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
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
int main(int argc, char const *argv[])
{
ll n, sum, fn;
cin >> n;
sum = (n * (n + 1)) / 2;
fn = floor( n/2 ) * 2;
if (sum&1)
{
cout << "NO";
return 0;
}
vector<ll> f, s;
for (ll i = 0; i < n / 2; i++)
{
if (i & 1)
{
f.push_back(i + 1);
f.push_back(fn - i );
}
else
{
s.push_back(i + 1);
s.push_back(fn - i );
}
}
if (n & 1)
{
if (accumulate(f.begin(), f.end(), 0) > accumulate(s.begin(), s.end(), 0))
{
s.push_back(n);
}
else
{
f.push_back(n);
}
}
cout << "YES" << endl;
cout << f.size() << endl;
for(ll val : f) {
cout << val << " ";
}
cout << endl << s.size() << endl;
for(ll val : s) {
cout << val << " ";
}
return 0;
}