27922023-01-25 09:23:20tamasmarkFasor (40)cpp17Hibás válasz 10/4072ms7436 KiB
//nemes fasor.cpp : This file contains the 'main' function.Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

vector<long long >x;
long long i, n, k, j;
bool t;

int main()
{
    cin >> n >> k;
    x.resize(n + 1);
    for (i = 1; i <= n; ++i)
    {
        cin >> x[i];
    }
    i = 1;
    while (i < x.size() - 1)
    {
        t = false;
        if (x[i] > x[i + 1])
        {
            for (j = i + 1; j <= k + i; ++j)
            {
                if (x[i] < x[j])
                {
                    i = j;
                    t = true;
                    break;
                }
            }
        }
        else if (x[i] < x[i + 1]) ++i;
        if (!t) break;
    }
    if (!t) cout << i;
    else cout << -1;
    return 0;
}
/*
10 3
6 2 1 8 4 8 7 12 9 3
*/
// 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base10/40
1Elfogadva0/03ms1872 KiB
2Elfogadva0/04ms2272 KiB
3Hibás válasz0/22ms2268 KiB
4Hibás válasz0/22ms2472 KiB
5Elfogadva2/22ms2676 KiB
6Hibás válasz0/22ms2760 KiB
7Elfogadva2/22ms3036 KiB
8Hibás válasz0/23ms3176 KiB
9Elfogadva2/24ms3304 KiB
10Hibás válasz0/26ms3304 KiB
11Hibás válasz0/26ms3304 KiB
12Elfogadva2/24ms3612 KiB
13Hibás válasz0/237ms4828 KiB
14Hibás válasz0/235ms4956 KiB
15Hibás válasz0/259ms6724 KiB
16Hibás válasz0/267ms6820 KiB
17Hibás válasz0/272ms6952 KiB
18Hibás válasz0/272ms6908 KiB
19Hibás válasz0/271ms6900 KiB
20Hibás válasz0/223ms5472 KiB
21Hibás válasz0/261ms7248 KiB
22Elfogadva2/272ms7436 KiB