256312026-02-23 19:09:01GeneratrollMediánok (40 pont)cpp17Accepted 40/4010ms1856 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> a(n + 1);
	for (int i = 1; i < k; ++i) {
		if (i % 2 != 0) {
			a[i] = n - (i - 1) / 2;
		} else {
			a[i] = i / 2;
		}
	}
	int low = (k - 1) / 2;
	int high = k / 2;
	int l = low + 1;
	int r = n - high;
	int nl = (n - k + (k % 2 == 0)) / 2;
	int ak = l + nl;
	a[k] = ak;
	vector<int> q1, q2;
	for (int x = l; x < ak; ++x) {
		q1.push_back(x);
	}
	for (int x = ak + 1; x <= r; ++x) {
		q2.push_back(x);
	}
	int p1 = 0, p2 = 0;
	for (int i = k + 1; i <= n; ++i) {
		if ((i - 1) % 2 == 0) {
			a[i] = q1[p1++];
		} else {
			a[i] = q2[p2++];
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << a[i] << (i == n ? "" : " ");
	}
	cout << '\n';
	return 0;
}

SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms316 KiB
2Accepted0/09ms1588 KiB
3Accepted1/11ms508 KiB
4Accepted1/12ms316 KiB
5Accepted1/11ms508 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms316 KiB
9Accepted1/11ms316 KiB
10Accepted1/11ms316 KiB
11Accepted1/11ms316 KiB
12Accepted1/11ms316 KiB
13Accepted1/11ms316 KiB
14Accepted1/11ms316 KiB
15Accepted1/11ms316 KiB
16Accepted1/11ms316 KiB
17Accepted1/11ms316 KiB
18Accepted1/11ms316 KiB
19Accepted1/11ms316 KiB
20Accepted1/11ms316 KiB
21Accepted1/19ms1748 KiB
22Accepted1/19ms1764 KiB
23Accepted1/110ms1840 KiB
24Accepted1/19ms1808 KiB
25Accepted1/19ms1856 KiB
26Accepted1/110ms1840 KiB
27Accepted1/18ms1332 KiB
28Accepted1/19ms1840 KiB
29Accepted1/19ms1588 KiB
30Accepted1/18ms1348 KiB
31Accepted1/19ms1332 KiB
32Accepted1/19ms1336 KiB
33Accepted1/110ms1840 KiB
34Accepted2/29ms1588 KiB
35Accepted1/19ms1332 KiB
36Accepted1/19ms1840 KiB
37Accepted2/29ms1588 KiB
38Accepted1/19ms1332 KiB
39Accepted1/18ms1404 KiB
40Accepted1/18ms1332 KiB