#include <iostream> #include <set> #include <map> #include <vector> #include <stack> #include <queue> #include <utility> #include <unordered_set> #include <unordered_map> #include <cmath> #include <climits> #include <cinttypes> #include <algorithm> using namespace std; typedef long long ll; typedef long int longi; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vpii; template <class T> int size(const T &x) { return x.size(); } const int INF = 2147483647; #define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i) #define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; longi total = 1LL * n * (n + 1) / 2; longi curr = 0; if (total % 2 != 0) { cout << "NO" << endl; return 0; } vector<int> a, b; a.reserve(n / 2); b.reserve(n / 2); cout << "YES" << endl; for (int i = n; i >= 1; i--) { if (curr + i <= total / 2) { a.push_back(i); curr += i; } else { b.push_back(i); } } cout << a.size() << endl; for (int i : a) cout << i << ' '; cout << endl; cout << b.size() << endl; for (int i : b) cout << i << ' '; cout << endl; return 0; } Frontend
Source:https://dev.to/guhan29/two-sets-cses-algoritmit-ongelmanratkaisussa-g43
Two Sets | CSES - Algoritmit ongelmanratkaisussa
dev.to0 views
PreviousLeer un neumático negro sobre negro: cómo hicimos Rodi Vision en la HackEPS 2026NextHow I Turn a Recorded Sprint Review Into Notes My Team Will Actually Read
Related posts
Two logical properties and 110 physical ones, so I set dir=rtl on all 106 of our pages
0dev.to
Flag a shared comparator before pooling trial results
0dev.to
Josephus Problem I | CSES - Algoritmit ongelmanratkaisussa
0dev.to
Kubernetes: email de prueba sin contaminar CI
0dev.to
I switched the stylesheet off on all 106 of our pages, and the only text that changed was the nav
0dev.to
What a faceless YouTube channel could save with AI voice: the math, with code
0dev.to