37862023-03-02 22:07:13TuruTamasMediánok (40 pont)cpp17Accepted 40/4014ms5092 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/03ms1748 KiB
2Accepted0/013ms1908 KiB
3Accepted1/12ms2120 KiB
4Accepted1/13ms2336 KiB
5Accepted1/13ms2544 KiB
6Accepted1/12ms2668 KiB
7Accepted1/13ms2908 KiB
8Accepted1/12ms2960 KiB
9Accepted1/12ms3088 KiB
10Accepted1/13ms3180 KiB
11Accepted1/12ms3268 KiB
12Accepted1/12ms3264 KiB
13Accepted1/13ms3544 KiB
14Accepted1/12ms3540 KiB
15Accepted1/13ms3556 KiB
16Accepted1/13ms3668 KiB
17Accepted1/13ms3624 KiB
18Accepted1/13ms3760 KiB
19Accepted1/13ms3976 KiB
20Accepted1/13ms4216 KiB
21Accepted1/114ms4456 KiB
22Accepted1/114ms4508 KiB
23Accepted1/114ms4632 KiB
24Accepted1/114ms4716 KiB
25Accepted1/114ms4808 KiB
26Accepted1/114ms4844 KiB
27Accepted1/114ms4900 KiB
28Accepted1/114ms4880 KiB
29Accepted1/114ms4876 KiB
30Accepted1/114ms4876 KiB
31Accepted1/114ms4872 KiB
32Accepted1/114ms4872 KiB
33Accepted1/114ms4992 KiB
34Accepted2/214ms5092 KiB
35Accepted1/114ms4872 KiB
36Accepted1/114ms4872 KiB
37Accepted2/214ms4872 KiB
38Accepted1/114ms4872 KiB
39Accepted1/114ms4876 KiB
40Accepted1/114ms4872 KiB