Source Code
#include "bits/stdc++.h"

#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O2")

using namespace std;
using ll = long long;
using ld = long double;

int dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

const int N = 2E6 + 5, M = 2E6 + 10, MOD = 1E9 + 7, OO = 0x3f3f3f3f;
ll x, a[N], idx;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    cin >> x;
    while (x - (idx+1) >= 0){
        a[idx] = idx+1, idx++;
        x -= idx;
    }
    if(x) a[idx-1] += x;

    cout << idx << '\n';
    for (int i = 0; i < idx; ++i)
        cout << a[i] << " \n"[i+1 == idx];

    return 0;
}
Copy
Want More! Redhwan
GNU G++17
153 ms
22.4 MB
Accepted