Cod sursa(job #2904072)

Utilizator NicuDirvaDirva Nicolae NicuDirva Data 17 mai 2022 22:08:48
Problema Farfurii Scor 0
Compilator cpp-64 Status done
Runda Teme Pregatire ACM Unibuc 2013 Marime 0.46 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

ifstream fin ("farfurii.in");
ofstream fout("farfurii.out");

int main()
{
long n, x, y, lg;

fin>>n>>x;

while(lg*(lg+1)>>1 <= x)
    lg++;

for(int i = 1; i <= n-lg - 1; i++)
    fout<<i<<" ";

y = lg * (lg+1) / 2 - x;

fout<<n - y <<" ";

for(int i = n; i >= n - lg; i--)
    if(i != n - y)
        fout<<i<<" ";

fin.close();
fout.close();

return 0;

}