Cod sursa(job #3369284)
| Utilizator | Data | 19 octombrie 2026 11:42:04 | |
|---|---|---|---|
| Problema | Farfurii | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <fstream>
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
int main()
{
int n, x = 1;
long long k;
fin >> n >> k;
while (1LL * x * (x - 1) / 2 < k) x++;
for (int i = 1; i <= n - x; i++) fout << i << " ";
int a = n - x + 1;
long long r = 1LL * x * (x - 1) / 2 - k;
fout << a + r << " ";
for (int i = n; i >= a; i--)
{
if (i != a + r) fout << i << " ";
}
return 0;
}