Source Code
#include <bits/stdc++.h>
using namespace std;
#define s second
#define f first
#define pb push_back
signed main()
{
    int cur=1;
    vector<int>ans;
    int curs=0;
    int x;
    cin>>x;
    while(curs<x)
    {
        if(curs+cur>x)
        {
            ans.back()+=x-curs;
            break;
        }
        curs+=cur;
        cur++;
        ans.pb(cur-1);
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<" \n"[i+1==ans.size()];
    return 0;
}
Copy
Want More! ahmedfouadnew
GNU G++17
281 ms
262.1 MB
Memory Limit Exceeded