Pagini recente » Cod sursa (job #549408) | Cod sursa (job #549462) | Cod sursa (job #3359927) | Cod sursa (job #3360951) | Cod sursa (job #3359523)
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
#ifndef LOCAL
cin.tie(nullptr)->sync_with_stdio(false);
freopen("farfurii.in", "r", stdin);
freopen("farfurii.out", "w", stdout);
#endif
int n, k; cin >> n >> k;
int s = 0;
vector<int> ans;
int backwards = n;
bool didntWork = false;
int point = 0;
for (int i = 1; i <= n; ++i) {
if (didntWork) {
ans.push_back(backwards--);
if (ans.back() == point)
ans.back() = backwards--;
continue;
}
int maxInversionsWithout = (n - i) * (n - i - 1) / 2;
if (maxInversionsWithout < k) {
didntWork = true;
ans.push_back(i + k - maxInversionsWithout);
point = ans.back();
continue;
}
ans.push_back(i);
}
for (auto& i : ans) cout << i << ' ';
cout << '\n';
return 0;
}