47202023-03-31 10:00:54csaron71Kombináció (50)cpp17Runtime error 37/504ms4244 KiB
#include <bits/stdc++.h>

using namespace std;

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

    int masik=-1, hol=m;
    while (masik==-1) {
        hol--;
        if (van[v[hol]-1]==0) {
            masik=v[hol]-1;
        }
    }

    int b=0;
    while (v[b]<masik) {
        cout << v[b]  << " ";
        b++;
    }
    cout << masik << " ";
    for (int i=n-(m-hol)+2; i<=n; i++) {
        cout << i << " ";
    }
    cout << "\n";

    int uj=-1, epp=m;
    while (uj==-1) {
        epp--;
        if (v[epp]<n && van[v[epp]+1]==0) {
            uj=v[epp]+1;
        }
    }
    int a=0;
    while (v[a]<uj-1) {
        cout << v[a] << " ";
        a++;
    }
    for (int i=uj; i<uj+m-epp; i++) {
        cout << i << " ";
    }



    return 0;
}
SubtaskSumTestVerdictTimeMemory
base37/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2008 KiB
3Runtime error0/23ms2060 KiB
4Accepted2/23ms2236 KiB
5Partially correct1/22ms2296 KiB
6Partially correct1/23ms2436 KiB
7Accepted2/23ms2688 KiB
8Wrong answer0/24ms2860 KiB
9Partially correct1/23ms3076 KiB
10Partially correct2/43ms3284 KiB
11Accepted4/43ms3532 KiB
12Accepted4/43ms3616 KiB
13Accepted4/43ms3752 KiB
14Wrong answer0/44ms3828 KiB
15Accepted4/43ms4044 KiB
16Accepted6/63ms4128 KiB
17Accepted6/62ms4244 KiB