7 more
This commit is contained in:
28
CSES - CSES Problem Set/Two_Sets.cpp
Normal file
28
CSES - CSES Problem Set/Two_Sets.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Two Sets
|
||||
|
||||
#include<bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
using ll = long long;
|
||||
|
||||
int main() {
|
||||
ll n; cin >> n;
|
||||
if ((n * (n+1) / 2) & 1) {
|
||||
cout << "NO" << endl;
|
||||
return 0;
|
||||
}
|
||||
cout << "YES" << endl;
|
||||
ll target_sum = n * (n+1) / 4;
|
||||
vector<ll> first;
|
||||
vector<ll> second;
|
||||
for (ll i = n; i > 0; i--) {
|
||||
if (i <= target_sum) {first.push_back(i); target_sum -= i;}
|
||||
else second.push_back(i);
|
||||
}
|
||||
cout << first.size() << endl;
|
||||
for (auto e : first) cout << e << " ";
|
||||
cout << '\n' << second.size() << '\n';
|
||||
for (auto e: second) cout << e << " ";
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user