37902023-03-02 22:16:35TuruTamasMediánok (40 pont)cpp17Runtime error 0/403ms4880 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);
    assert(N<=100000);
    assert(K<=N);
    assert(K>=1);
    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
base0/40
1Runtime error0/03ms2212 KiB
2Runtime error0/03ms2268 KiB
3Runtime error0/13ms2492 KiB
4Runtime error0/13ms2724 KiB
5Runtime error0/13ms2940 KiB
6Runtime error0/13ms3112 KiB
7Runtime error0/13ms3400 KiB
8Runtime error0/13ms3340 KiB
9Runtime error0/13ms3696 KiB
10Runtime error0/13ms3520 KiB
11Runtime error0/13ms3520 KiB
12Runtime error0/13ms3536 KiB
13Runtime error0/13ms3648 KiB
14Runtime error0/13ms3740 KiB
15Runtime error0/13ms3828 KiB
16Runtime error0/13ms3628 KiB
17Runtime error0/13ms3736 KiB
18Runtime error0/13ms3728 KiB
19Runtime error0/13ms3736 KiB
20Runtime error0/13ms3964 KiB
21Runtime error0/13ms3968 KiB
22Runtime error0/13ms3964 KiB
23Runtime error0/13ms3964 KiB
24Runtime error0/13ms3964 KiB
25Runtime error0/13ms3968 KiB
26Runtime error0/13ms4192 KiB
27Runtime error0/13ms4300 KiB
28Runtime error0/13ms4316 KiB
29Runtime error0/13ms4436 KiB
30Runtime error0/13ms4440 KiB
31Runtime error0/13ms4552 KiB
32Runtime error0/13ms4660 KiB
33Runtime error0/13ms4572 KiB
34Runtime error0/23ms4692 KiB
35Runtime error0/13ms4680 KiB
36Runtime error0/13ms4712 KiB
37Runtime error0/23ms4716 KiB
38Runtime error0/13ms4832 KiB
39Runtime error0/13ms4816 KiB
40Runtime error0/13ms4880 KiB