Cod sursa(job #1743370)

Utilizator fanache99Constantin-Buliga Stefan fanache99 Data 18 august 2016 01:57:50
Problema Multimi2 Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <fstream>
#include <cstring>
using namespace std;

ifstream cin("multimi2.in");
ofstream cout("multimi2.out");

const int MAXN = 1000000;

char where[1 + MAXN];

int main() {
    int n;
    cin >> n;
    long long sum = 1LL * n * (n + 1) / 2;
    long long half = sum / 2;
    long long left = 0, right = 0;
    int number = 0;
    for (int i = n; i >= 1; i--)
        if (i > half) {
            where[i] = 2;
            right += i;
        }
        else {
            where[i] = 1;
            left += i;
            half -= i;
            number++;
        }
    cout << right - left << "\n" << n - number << "\n";
    for (int i = 1; i <= n; i++)
        if (where[i] == 2)
            cout << i << " ";
    cout << "\n" << number << "\n";
    for (int i = 1; i <= n; i++)
        if (where[i] == 1)
            cout << i << " ";
    return 0;
}