90122024-02-12 09:21:36akososkaKombináció (50)cpp17Accepted 50/503ms3880 KiB
#include <iostream>

using namespace std;
int n,m;

int main()
{
    cin>>m;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int k=n;
    if(a[n]==n){
        for(int i=1;i<=n;i++){
            cout<<m-n+i<<" ";
        }
    }
    else{
        while(k>=2&& a[k]-a[k-1]==1)k--;
        for(int i=1;i<k;i++){
            cout<<a[i]<<" ";
        }
        cout<<a[k]-1<<" ";
        for(int i=k+1;i<=n;i++){
            cout<<m+i-n<<" ";
        }
    }
    cout<<endl;
    if(a[1]==m-n+1) for(int i=1;i<=n;i++) cout<<i<<" ";
    else{
        k=n;
        int s=m+1;
        while(k>=2 && s-a[k]==1){s=a[k];k--;}
        for(int i=1;i<k;i++){
            cout<<a[i]<<" ";
        }
        cout<<a[k]+1<<" ";
        for(int i=k+1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1872 KiB
2Accepted0/03ms2128 KiB
3Accepted2/22ms2160 KiB
4Accepted2/23ms2288 KiB
5Accepted2/23ms2632 KiB
6Accepted2/23ms2760 KiB
7Accepted2/23ms2976 KiB
8Accepted2/23ms3024 KiB
9Accepted2/23ms3156 KiB
10Accepted4/43ms3248 KiB
11Accepted4/43ms3380 KiB
12Accepted4/43ms3492 KiB
13Accepted4/43ms3652 KiB
14Accepted4/43ms3636 KiB
15Accepted4/43ms3864 KiB
16Accepted6/63ms3880 KiB
17Accepted6/63ms3848 KiB