Cod sursa(job #2939942)
| Utilizator | Data | 14 noiembrie 2022 15:33:05 | |
|---|---|---|---|
| Problema | Farfurii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
const int NMAX = 1e5+5;
long long n, k, arr[NMAX];
inline void solve()
{
long long cnt = 1, a;
while(cnt * (cnt + 1) <= k * 2)
cnt++;
for(int i=1;i<n-cnt;++i)
fout << i << ' ';
a = n - (cnt * (cnt + 1) /2 - k);
fout << a << ' ';
for(int i=n;n-cnt<=i;--i)
if(i!=a)
fout << i << ' ';
}
int main()
{
fin >> n >> k;
solve();
}
