Source Code
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 7;
long long n;

int main()
{
       ios_base::sync_with_stdio(0);
       cin.tie(0);
#ifndef ONLINE_JUDGE
#endif
       cin >> n; 
       vector<long long> ans ;
       long long cur = 1; 
       while(n>=cur){
              ans.push_back(cur) ; 
              n-= cur++;
       }
       if(n)ans.push_back(cur) , n-= cur; 
       cout << ans.size() - !! n << endl ; 
       for(auto u: ans){
              if(u == -n){
                     continue ;
              }
              cout << u << ' ' ;
       }

       return 0;
}
Copy
Want More! Mohamed.Sobhy
GNU G++17
144 ms
22.4 MB
Accepted