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

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
auto start = chrono::steady_clock::now();
void init_code(){
    fast_io;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
}
int main(){
    int t;
    cin>>t;
    int n=(-1+sqrt((1+8*t))/2);
    int a=(n*(n+1))/2;
    cout<<a<<endl;
    if(a==t){
        cout<<n<<endl;
        for(int i=1;i<n+1;i++) cout<<i<<" ";
    }else{
        int d=t-a;
        if(d<n+1){
            cout<<n<<endl;
            for(int i=1;i<n;i++) cout<<i<<" ";
            cout<<n+d;
        }else{
            cout<<n+1<<endl;
            for(int i=1;i<n+1;i++) cout<<i<<" ";
            cout<<d;
        }
    }
   return(0);
}
Copy
Want More! bbmm
GNU G++17
1 ms
360 KB
Wrong Answer