Source Code
#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 1;
int main() {
    long long x;
    cin >> x;
    vector <int> v;
    int Ans = 0;
    for (long long i = 1; (i * (i + 1) ) / 2 <= x; i++){
        long long sum = (i * (i + 1)) / 2;
        if (x - sum > i || x - sum == 0) {
            Ans = i;
        }
    }
    for (int i=1;i<=Ans;i++)v.push_back(i), x-=i;
    if (x)v.push_back(x);
    cout << v.size() << endl;
    for (int u : v) printf("%d ", u);
}
Copy
Want More! Random Bruh
GNU G++17
170 ms
16.6 MB
Accepted