#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
What a faceless YouTube channel could save with AI voice: the math, with code
0dev.to
How two unused $18 tools cost $432 a year: a 10-minute audit script
0dev.to
Creating Strings | CSES - Algoritmit ongelmanratkaisussa
0dev.to
A quiet breathing practice in the browser, with no account and no chat
0dev.to

Крайности и баланс между ними
0dev.to
3 ways to show a JSON API response in your docs (and keep it readable)
0dev.to