37872023-03-02 22:07:23rennMediánok (40 pont)cpp17Accepted 40/4010ms4776 KiB
#include <bits/stdc++.h>
using namespace std;
#define GOTTAGOFAST ios::sync_with_stdio(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/03ms2168 KiB
2Accepted0/09ms2332 KiB
3Accepted1/13ms2336 KiB
4Accepted1/12ms2552 KiB
5Accepted1/12ms2716 KiB
6Accepted1/12ms2764 KiB
7Accepted1/13ms2780 KiB
8Accepted1/13ms2908 KiB
9Accepted1/13ms3132 KiB
10Accepted1/12ms3200 KiB
11Accepted1/13ms3348 KiB
12Accepted1/13ms3268 KiB
13Accepted1/13ms3372 KiB
14Accepted1/12ms3272 KiB
15Accepted1/13ms3396 KiB
16Accepted1/13ms3596 KiB
17Accepted1/13ms3684 KiB
18Accepted1/13ms3684 KiB
19Accepted1/13ms3780 KiB
20Accepted1/13ms3776 KiB
21Accepted1/19ms3712 KiB
22Accepted1/19ms3716 KiB
23Accepted1/19ms3748 KiB
24Accepted1/19ms3748 KiB
25Accepted1/19ms3960 KiB
26Accepted1/19ms4176 KiB
27Accepted1/19ms4168 KiB
28Accepted1/19ms4148 KiB
29Accepted1/19ms4148 KiB
30Accepted1/19ms4060 KiB
31Accepted1/19ms4108 KiB
32Accepted1/19ms4060 KiB
33Accepted1/19ms4084 KiB
34Accepted2/29ms4060 KiB
35Accepted1/110ms4060 KiB
36Accepted1/19ms4060 KiB
37Accepted2/29ms4272 KiB
38Accepted1/19ms4476 KiB
39Accepted1/110ms4776 KiB
40Accepted1/19ms4660 KiB