249522026-02-17 07:50:14szabelrKombináció (50)cpp17Elfogadva 50/502ms536 KiB
// Előző és következő ülés sorrend.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++)
        cin >> x[i];
    //kisebb
    bool ok = false;
    vector<int> og = x;
    for (int i = m-1; i >= 0; i--)
    {
        if ((i == 0 and x[i] > 1) or (i > 0 and x[i] - 1 > x[i - 1]))
        {
            ok = true;
            x[i]--;
            for (int y = i+1; y < m; y++)
            {
                x[y] = n-m+y+1;
            }
            break;
        }
    }
    if (!ok)
    {
        for (int y = 0; y < m; y++)
        {
            x[y] = n - m + y + 1;
        }
    }
    for (auto a : x)
        cout << a << " ";
    cout << endl;
    ok = false;
    for (int i = m - 1; i >= 0; i--)
    {
        if (og[i]<n-m+i+1)
        {
            ok = true;
            og[i]++;
            for (int y = i + 1; y < m; y++)
            {
                og[y] = og[y-1]+1;
            }
            break;
        }
    }
    if (!ok)
    {
        og[0] = 1;
        for (int y = 1; y < m; y++)
        {
            og[y] = og[y-1] + 1;
        }
    }
    for (auto a : og)
        cout << a << " ";

}

RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/01ms316 KiB
2Elfogadva0/01ms316 KiB
3Elfogadva2/21ms316 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva2/21ms316 KiB
9Elfogadva2/22ms316 KiB
10Elfogadva4/41ms316 KiB
11Elfogadva4/41ms316 KiB
12Elfogadva4/41ms512 KiB
13Elfogadva4/41ms536 KiB
14Elfogadva4/41ms316 KiB
15Elfogadva4/41ms316 KiB
16Elfogadva6/61ms316 KiB
17Elfogadva6/61ms508 KiB