109652024-04-22 16:04:23VargusKombináció (50)cpp17Wrong answer 35/503ms3932 KiB
#include <iostream>
#include <queue>
#define ll long long

using namespace std;

vector <ll> x, y, z;
ll n, k;

bool jo(ll lep)
{
    if (y[lep - 1] <= y[lep] && y[lep] >= x[lep])
        return true;
    return false;
}

int main()
{
    cin >> n >> k;
    x.resize(k + 1);
    y.resize(k + 1);
    z.resize(k + 1);
    for (ll i = 1; i <= k; ++i)
    {
        cin >> x[i];
        y[i] = x[i];
        z[i] = x[i];
    }

    ll n1;
    for (ll i = k; i >= 1; --i)
    {
        n1 = n - k + i;
        if (y[i] != n1)
        {
            y[i]++;
            for (ll j = i + 1; j <= k; ++j)
                y[j] = y[j - 1] + 1;
            break;
        }
    }

    bool ok = false;
    for (ll i = 1; i <= k; ++i)
    {
        n1 = n - k + i;
        if (z[i] == n1)
        {
            z[i]--;
            ok = true;
            break;
        }
    }
    if (!ok)
    {
        z[1]--;
        for (ll i = 2; i <= k; ++i)
            z[i]++;
    }

    for (ll i = 1; i <= k; ++i)
        cout << z[i] << " ";

    cout << "\n";
    for (ll i = 1; i <= k; ++i)
        cout << y[i] << " ";

    return 0;
}
/*
6 4
1 4 5 6

5 3
3 4 5
*/
SubtaskSumTestVerdictTimeMemory
base35/50
1Accepted0/03ms1748 KiB
2Wrong answer0/03ms1992 KiB
3Partially correct1/23ms2232 KiB
4Accepted2/23ms2484 KiB
5Partially correct1/23ms2632 KiB
6Partially correct1/23ms2836 KiB
7Partially correct1/23ms3052 KiB
8Partially correct1/23ms3056 KiB
9Partially correct1/23ms3184 KiB
10Partially correct2/43ms3268 KiB
11Accepted4/43ms3268 KiB
12Accepted4/43ms3392 KiB
13Accepted4/43ms3480 KiB
14Partially correct2/43ms3724 KiB
15Partially correct2/43ms3724 KiB
16Accepted6/63ms3848 KiB
17Partially correct3/63ms3932 KiB