Cod sursa(job #2653859)

Utilizator OvidRata Ovidiu Ovid Data 29 septembrie 2020 13:11:55
Problema Farfurii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.86 kb
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


ifstream fin("farfurii.in"); ofstream fout("farfurii.out");
#define cin fin
#define cout fout

int t, n, m, k, a[300010], q, l, r;

int32_t main(){
INIT
cin>>n>>k;
for(;(m*(m-1)/2)<k; m++){
}
int d=(m*(m-1)/2)-k;
for(int i=1; i<=(n-m); i++){
    cout<<i<<" ";
}

set<int> s; for(int i=n; i>(n-m); i--){s.insert(i); }
cout<<(n-d)<<" "; s.erase(s.find(n-d));
while(!s.empty()){
    auto it=s.end(); it--;
    cout<<(*it)<<" ";
     s.erase(it);
}

return 0;
}