-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8. Two Sets.cpp
More file actions
47 lines (40 loc) · 860 Bytes
/
8. Two Sets.cpp
File metadata and controls
47 lines (40 loc) · 860 Bytes
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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n;
cin >> n;
set<ll> arr1, arr2;
ll sum1 = 0, sum2 = 0;
for(ll i=n; i>0; i--)
{
if(sum1 <= sum2)
{
arr1.insert(i);
sum1 += i;
}
else
{
arr2.insert(i);
sum2 += i;
}
}
if(sum1 == sum2)
{
cout << "YES" << "\n";
cout << arr1.size() << "\n";
for(auto itr=arr1.begin(); itr!=arr1.end(); itr++)
cout << *itr << " ";
cout << "\n";
cout << arr2.size() << "\n";
for(auto itr=arr2.begin(); itr!=arr2.end(); itr++)
cout << *itr << " ";
cout << "\n";
}
else
{
cout << "NO" << "\n";
}
return 0;
}