37842023-03-02 22:05:48rennMediánok (40 pont)cpp17Accepted 40/4014ms4476 KiB
#include <bits/stdc++.h>
using namespace std;
#define GOTTAGOFAST cin.tie(0); cout.tie(0);

int main()
{
    GOTTAGOFAST
    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/03ms1872 KiB
2Accepted0/013ms2076 KiB
3Accepted1/13ms2192 KiB
4Accepted1/13ms2388 KiB
5Accepted1/12ms2476 KiB
6Accepted1/13ms2628 KiB
7Accepted1/12ms2640 KiB
8Accepted1/13ms2864 KiB
9Accepted1/12ms2944 KiB
10Accepted1/13ms3072 KiB
11Accepted1/13ms3288 KiB
12Accepted1/12ms3368 KiB
13Accepted1/13ms3260 KiB
14Accepted1/13ms3264 KiB
15Accepted1/13ms3496 KiB
16Accepted1/13ms3604 KiB
17Accepted1/13ms3716 KiB
18Accepted1/13ms3684 KiB
19Accepted1/13ms3804 KiB
20Accepted1/13ms3832 KiB
21Accepted1/114ms3880 KiB
22Accepted1/114ms3968 KiB
23Accepted1/114ms3968 KiB
24Accepted1/114ms3968 KiB
25Accepted1/114ms3968 KiB
26Accepted1/114ms4068 KiB
27Accepted1/114ms4096 KiB
28Accepted1/114ms4180 KiB
29Accepted1/114ms4452 KiB
30Accepted1/114ms4376 KiB
31Accepted1/114ms4376 KiB
32Accepted1/114ms4384 KiB
33Accepted1/114ms4380 KiB
34Accepted2/214ms4392 KiB
35Accepted1/114ms4408 KiB
36Accepted1/114ms4476 KiB
37Accepted2/214ms4468 KiB
38Accepted1/114ms4400 KiB
39Accepted1/114ms4428 KiB
40Accepted1/114ms4404 KiB