40182023-03-09 08:31:33szabel26Kombináció (50)cpp17Wrong answer 41/503ms4216 KiB
// kombinacio.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#define ll long long
using namespace std;

ll n, m, i, akt;

int main()
{
    cin >> n >> m;

    vector<ll>x(m + 1), elozo(m + 1), utana(m + 1);

    for (i = 1; i <= m; ++i)
    {
        cin >> x[i];
        elozo[i] = x[i];
        utana[i] = x[i];
    }

    for (i = m; i >= 1; --i)
    {
        if (i == 1)
        {
            if (elozo[i] > 1)
            {
                --elozo[i];
                break;
            }
        }
        else
        {
            if (elozo[i] - 1 > elozo[i - 1])
            {
                --elozo[i];
                break;
            }
        }
    }

    for (i = m; i >= 1; --i)
    {
        if (i == m)
        {
            if (utana[i] + 1 <= n)
            {
                ++utana[i];
                break;
            }
        }
        else
        {
            if (utana[i] + 1 < utana[i + 1])
            {
                ++utana[i];
                break;
            }
        }
    }

    for (i = 1; i <= m; ++i)
    {
        cout << elozo[i] << " ";
    }
    cout << "\n";
    for (i = 1; i <= m; ++i)
    {
        cout << utana[i] << " ";
    }
    return 0;
}

/*
6 4
1 2 4 6
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base41/50
1Accepted0/03ms1812 KiB
2Wrong answer0/03ms2052 KiB
3Accepted2/23ms2264 KiB
4Accepted2/23ms2468 KiB
5Partially correct1/23ms2680 KiB
6Partially correct1/23ms2856 KiB
7Partially correct1/22ms2964 KiB
8Accepted2/23ms2992 KiB
9Partially correct1/23ms3160 KiB
10Partially correct2/42ms3248 KiB
11Accepted4/42ms3376 KiB
12Accepted4/43ms3628 KiB
13Accepted4/43ms3836 KiB
14Accepted4/43ms4088 KiB
15Accepted4/42ms4132 KiB
16Accepted6/62ms4216 KiB
17Partially correct3/62ms4100 KiB