93002024-02-20 11:39:06zsebiKombináció (50)cpp17Wrong answer 41/503ms3584 KiB
// ulesrend2.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>

#define ll long long 
using namespace std;
vector<int>stati, comb,elo,uto;
ll n, k,j;
void eloz()
{
    for (int i = k; i >= 1; --i)
    {
        j = comb[i] - 1;
        while (stati[j])
        {
            --j;
        }
        if (j > comb[i - 1]&&j<comb[i+1])
        {
            elo[i] = j;
            break;
        }
    }
}
void utana()
{
    for (int i = k; i >= 1; --i)
    {
         j = comb[i] + 1;
        while (j<n &&stati[j])
        {
            ++j;
        }
        if (j<=n && j > comb[i - 1]&&j<comb[i+1])
        {
            uto[i] = j;
            break;
        }
    }
}
int main()
{
    cin >> n >> k;
    stati.assign(n + 1, 0);
    comb.assign(k + 2, 101);
    elo.assign(k + 1, 0);
    uto.assign(k + 1, 0);
    for (int i = 1; i <= k; ++i)
    {
        cin >> comb[i];
        stati[comb[i]] = 1;
    }
    comb[0] = 0;
    eloz();
    utana();
    for (int i = 1; i <= k; ++i)
    {
        if (elo[i])cout << elo[i] << " ";
        else cout << comb[i]<<" ";
    }
    cout << "\n";
    for (int i = 1; i <= k; ++i)
    {
        if (uto[i])cout << uto [i] << " ";
        else cout << comb[i]<<" ";
    }

    return 0;
}

// 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/03ms1876 KiB
2Wrong answer0/03ms2068 KiB
3Accepted2/23ms2292 KiB
4Accepted2/22ms2376 KiB
5Partially correct1/23ms2512 KiB
6Partially correct1/23ms2748 KiB
7Partially correct1/22ms2808 KiB
8Accepted2/23ms2964 KiB
9Partially correct1/22ms3056 KiB
10Partially correct2/43ms3084 KiB
11Accepted4/43ms3076 KiB
12Accepted4/43ms3208 KiB
13Accepted4/42ms3292 KiB
14Accepted4/43ms3300 KiB
15Accepted4/43ms3304 KiB
16Accepted6/63ms3508 KiB
17Partially correct3/63ms3584 KiB