Files
cses/CSES - CSES Problem Set/Two_Sets.cpp
2024-06-01 23:50:25 +02:00

29 lines
646 B
C++

// 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;
}