37892023-03-02 22:15:58TuruTamasMediánok (40 pont)cpp17Runtime error 0/403ms4784 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<=100);
    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/03ms1812 KiB
2Runtime error0/03ms2080 KiB
3Runtime error0/13ms2216 KiB
4Runtime error0/13ms2428 KiB
5Runtime error0/13ms2648 KiB
6Runtime error0/13ms2720 KiB
7Runtime error0/13ms2828 KiB
8Runtime error0/13ms3040 KiB
9Runtime error0/13ms3124 KiB
10Runtime error0/13ms3256 KiB
11Runtime error0/13ms3340 KiB
12Runtime error0/13ms3464 KiB
13Runtime error0/13ms3680 KiB
14Runtime error0/13ms3764 KiB
15Runtime error0/13ms3764 KiB
16Runtime error0/13ms3764 KiB
17Runtime error0/13ms3912 KiB
18Runtime error0/13ms3844 KiB
19Runtime error0/13ms3844 KiB
20Runtime error0/13ms4080 KiB
21Runtime error0/13ms4304 KiB
22Runtime error0/13ms4288 KiB
23Runtime error0/13ms4392 KiB
24Runtime error0/13ms4316 KiB
25Runtime error0/13ms4408 KiB
26Runtime error0/13ms4376 KiB
27Runtime error0/13ms4624 KiB
28Runtime error0/13ms4680 KiB
29Runtime error0/13ms4684 KiB
30Runtime error0/13ms4584 KiB
31Runtime error0/13ms4680 KiB
32Runtime error0/13ms4584 KiB
33Runtime error0/13ms4556 KiB
34Runtime error0/23ms4656 KiB
35Runtime error0/13ms4648 KiB
36Runtime error0/13ms4544 KiB
37Runtime error0/23ms4496 KiB
38Runtime error0/13ms4600 KiB
39Runtime error0/13ms4688 KiB
40Runtime error0/13ms4784 KiB