37912023-03-02 22:18:28TuruTamasMediánok (40 pont)cpp17Accepted 40/4010ms4884 KiB
//
// Created by tamas on 3/2/2023.
//
#include "bits/stdc++.h"
#include <cassert>
#include <cstdio>

using namespace std;

int N, K, i, mid;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> N >> K;
    assert(N<=100000);
    assert(K<=N);
    assert(K>=1);
    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/09ms2208 KiB
3Accepted1/12ms2168 KiB
4Accepted1/13ms2192 KiB
5Accepted1/13ms2400 KiB
6Accepted1/12ms2500 KiB
7Accepted1/12ms2720 KiB
8Accepted1/13ms2936 KiB
9Accepted1/12ms3148 KiB
10Accepted1/12ms3236 KiB
11Accepted1/12ms3244 KiB
12Accepted1/12ms3472 KiB
13Accepted1/12ms3544 KiB
14Accepted1/13ms3764 KiB
15Accepted1/12ms3848 KiB
16Accepted1/13ms3884 KiB
17Accepted1/12ms3968 KiB
18Accepted1/12ms4064 KiB
19Accepted1/12ms4340 KiB
20Accepted1/12ms4092 KiB
21Accepted1/110ms4132 KiB
22Accepted1/110ms4336 KiB
23Accepted1/110ms4524 KiB
24Accepted1/110ms4724 KiB
25Accepted1/110ms4640 KiB
26Accepted1/110ms4648 KiB
27Accepted1/19ms4680 KiB
28Accepted1/110ms4656 KiB
29Accepted1/110ms4672 KiB
30Accepted1/19ms4664 KiB
31Accepted1/110ms4672 KiB
32Accepted1/110ms4632 KiB
33Accepted1/110ms4632 KiB
34Accepted2/210ms4676 KiB
35Accepted1/110ms4688 KiB
36Accepted1/110ms4672 KiB
37Accepted2/210ms4684 KiB
38Accepted1/110ms4856 KiB
39Accepted1/110ms4844 KiB
40Accepted1/110ms4884 KiB