43732023-03-27 10:57:16ZsofiaKeresztelyKombináció (50)cpp14Partially correct 36/503ms3828 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i=0; i<m; i++){
        cin >> a[i];
    }
    int c=1;
    while (c < m && a[m-c-1] + 1 == a[m-c]){
        c++;
    }
    for (int i=0; i<m-c; i++){
        cout << a[i] << " ";
    }
    cout << (a[m-c]-1 ? a[m-c]-1 : n-m+1);
    for (int i=c-2; i>=0; i--){
        cout << " " << n-i;
    }
    cout << "\n";
    for (int i=0; i<m-c-1; i++){
        cout << a[i] << " ";
    }
    if (a.back() != n){
        for (int i=m-c-1; i<m-1; i++){
            cout << a[i] << " ";
        }
        cout << a[m-1] + 1;
    }
    else{
        int x = (m-c-1 ? a[m-c-1] : 0);
        for (int i=x+1; i<=x+c+1; i++){
            cout << i << " ";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base36/50
1Accepted0/03ms1820 KiB
2Accepted0/03ms2056 KiB
3Partially correct1/23ms2264 KiB
4Partially correct1/23ms2480 KiB
5Partially correct1/23ms2680 KiB
6Partially correct1/23ms2852 KiB
7Accepted2/22ms2932 KiB
8Partially correct1/23ms3072 KiB
9Partially correct1/23ms3288 KiB
10Partially correct2/43ms3372 KiB
11Partially correct2/43ms3488 KiB
12Accepted4/42ms3484 KiB
13Partially correct2/43ms3488 KiB
14Partially correct2/43ms3612 KiB
15Accepted4/43ms3700 KiB
16Accepted6/63ms3584 KiB
17Accepted6/63ms3828 KiB