37852023-03-02 22:06:13rennMediánok (40 pont)cpp17Accepted 40/4014ms5016 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, k, med, i;
    cin >> n >> k;

    int pmin=1, pmax=n;
    med = n/2 + (n&1); // a medián

    bool sw = true;

    for(i = 1; i <= n; i++)
    {
        if(i == k)
        {
            cout << med << " ";
            continue;
        }
        
        sw = !sw;
        if(sw)
        {
            cout << pmin << " ";
            pmin += 1 + (pmin == med);
            continue;
        }

        cout << pmax << " ";
        pmax -= 1 + (pmax == med);
    }
    cout << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms2020 KiB
2Accepted0/013ms2104 KiB
3Accepted1/13ms2320 KiB
4Accepted1/13ms2528 KiB
5Accepted1/13ms2744 KiB
6Accepted1/12ms2948 KiB
7Accepted1/12ms3084 KiB
8Accepted1/12ms3164 KiB
9Accepted1/12ms3444 KiB
10Accepted1/12ms3288 KiB
11Accepted1/12ms3324 KiB
12Accepted1/12ms3460 KiB
13Accepted1/12ms3576 KiB
14Accepted1/13ms3664 KiB
15Accepted1/13ms3920 KiB
16Accepted1/13ms4000 KiB
17Accepted1/13ms3960 KiB
18Accepted1/13ms4096 KiB
19Accepted1/13ms4304 KiB
20Accepted1/13ms4544 KiB
21Accepted1/114ms4632 KiB
22Accepted1/114ms4596 KiB
23Accepted1/114ms4600 KiB
24Accepted1/114ms4708 KiB
25Accepted1/114ms4600 KiB
26Accepted1/114ms4600 KiB
27Accepted1/114ms4680 KiB
28Accepted1/114ms4676 KiB
29Accepted1/114ms4676 KiB
30Accepted1/114ms4924 KiB
31Accepted1/114ms4808 KiB
32Accepted1/114ms4888 KiB
33Accepted1/114ms4944 KiB
34Accepted2/214ms4880 KiB
35Accepted1/114ms4824 KiB
36Accepted1/114ms4808 KiB
37Accepted2/214ms4812 KiB
38Accepted1/114ms4920 KiB
39Accepted1/114ms5016 KiB
40Accepted1/114ms4812 KiB