47912023-03-31 12:31:45AblablablaKombináció (50)cpp17Partially correct 44/503ms3480 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ules(m + 2, 0);
    ules[m + 1] = n;
    for(int i = 1; i <= m; i++){
        cin >> ules[i];
    }

    int valtas = m;
    while(valtas > 0 && ules[valtas] - ules[valtas - 1] <= 1){
        valtas--;
    }

    //cout << valtas << "\n";
    if(valtas == 0){
        // legkisebb eset -> legnagyobbat kell kiirni
        for(int i = 1; i <= m; i++){
            cout << n - m + i << " ";
        }
    } else{
        for(int i = 1; i <= m; i++){
            if(valtas == i){
                cout << ules[i] - 1 << " ";
                for(int j = i + 1; j <= m; j++){
                    cout << n - m + j << " ";
                }
                break;
            } else{
                cout << ules[i] << " ";
            }
        }
    }

    cout << "\n";

    valtas = m;
    while(valtas > 0 && ules[valtas + 1] - ules[valtas] <= 1){
        valtas--;
    }

    //cout << valtas << "\n";

    if(valtas == 0){
        // legnagyobb eset -> legkisebbet kell kiirni
        for(int i = 1; i <= m; i++){
            cout << i << " ";
        }
    } else{
        for(int i = 1; i <= m; i++){
            if(valtas == i){
                cout << ules[i] + 1 << " ";
                for(int j = ules[i] + 2; i < m; j++){
                    cout << j << " ";
                    i++;
                }
            } else{
                cout << ules[i] << " ";
            }
        }
    }

    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2000 KiB
3Accepted2/23ms2212 KiB
4Accepted2/22ms2296 KiB
5Accepted2/22ms2296 KiB
6Accepted2/23ms2432 KiB
7Partially correct1/22ms2540 KiB
8Accepted2/23ms2640 KiB
9Accepted2/23ms2852 KiB
10Accepted4/43ms3064 KiB
11Accepted4/42ms3148 KiB
12Accepted4/43ms3284 KiB
13Accepted4/42ms3272 KiB
14Accepted4/43ms3360 KiB
15Partially correct2/43ms3480 KiB
16Accepted6/62ms3244 KiB
17Partially correct3/63ms3364 KiB