37712023-03-02 21:41:09TuruTamasMediánok (40 pont)cpp17Accepted 40/409ms4648 KiB
//
// Created by tamas on 3/2/2023.
//
#include "bits/stdc++.h"
#include <cstdio>

using namespace std;

int N, K, i, mid;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> N >> K;
    if (K % 2 == 1) {
        for (i = 0; i <= K/2-1; ++i) {
            cout << N-i << " " << i+1 << " ";
        }
        mid = N/2+N%2;
        cout << mid << " ";
        for (i = 1; i <= mid-K/2-1; ++i) {
            cout << mid+i << " " << mid-i << " ";
        }
        if (N%2 == 0) {
            cout << N-K/2;
        }
    }
    else {
        for (i = 0; i <= K/2-2; ++i) {
            cout << N-i << " " << i+1 << " ";
        }
        cout << N-K/2+1 << " ";
        mid = N/2+N%2;
        cout << mid << " ";
        for (i = 1; i <= N-K/2-mid; ++i) {
            cout << mid-i << " " << mid+i << " ";
        }
        if (N%2 == 1) {
            cout << K/2;
        }
    }
    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1888 KiB
2Accepted0/09ms2244 KiB
3Accepted1/12ms2308 KiB
4Accepted1/12ms2520 KiB
5Accepted1/13ms2760 KiB
6Accepted1/12ms2832 KiB
7Accepted1/12ms2944 KiB
8Accepted1/13ms3156 KiB
9Accepted1/13ms3380 KiB
10Accepted1/12ms3472 KiB
11Accepted1/12ms3596 KiB
12Accepted1/13ms3832 KiB
13Accepted1/12ms3904 KiB
14Accepted1/12ms3880 KiB
15Accepted1/13ms4012 KiB
16Accepted1/13ms4224 KiB
17Accepted1/13ms4312 KiB
18Accepted1/12ms4308 KiB
19Accepted1/12ms4304 KiB
20Accepted1/13ms4312 KiB
21Accepted1/19ms4372 KiB
22Accepted1/19ms4476 KiB
23Accepted1/19ms4456 KiB
24Accepted1/19ms4352 KiB
25Accepted1/19ms4552 KiB
26Accepted1/19ms4648 KiB
27Accepted1/19ms4648 KiB
28Accepted1/19ms4552 KiB
29Accepted1/19ms4548 KiB
30Accepted1/19ms4560 KiB
31Accepted1/19ms4628 KiB
32Accepted1/19ms4564 KiB
33Accepted1/19ms4572 KiB
34Accepted2/29ms4596 KiB
35Accepted1/19ms4632 KiB
36Accepted1/19ms4564 KiB
37Accepted2/29ms4604 KiB
38Accepted1/19ms4588 KiB
39Accepted1/19ms4580 KiB
40Accepted1/19ms4588 KiB