2793 2023. 01. 25 09:48:22 tamasmark Fasor (40) cpp17 Időlimit túllépés 14/40 300ms 7052 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,db;
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])
        {
            db = 0;
            for (j = i+2; j <= k + i&&j<=n; ++j)
            {
                if (x[i] < x[j]&&j>=0&&j<=n)
                {
                    i = j;
                    break;
                }
                else db++;
                if (db == k-1||j==n) t = true;
            }
        }
        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 Összpont Teszt Verdikt Idő Memória
base 14/40
1 Elfogadva 0/0 3ms 1744 KiB
2 Elfogadva 0/0 4ms 2120 KiB
3 Időlimit túllépés 0/2 231ms 2092 KiB
4 Hibás válasz 0/2 2ms 2320 KiB
5 Időlimit túllépés 0/2 300ms 2372 KiB
6 Elfogadva 2/2 2ms 2524 KiB
7 Elfogadva 2/2 2ms 2748 KiB
8 Elfogadva 2/2 3ms 2980 KiB
9 Elfogadva 2/2 4ms 3092 KiB
10 Elfogadva 2/2 6ms 3384 KiB
11 Időlimit túllépés 0/2 300ms 3300 KiB
12 Elfogadva 2/2 4ms 3592 KiB
13 Időlimit túllépés 0/2 300ms 3400 KiB
14 Időlimit túllépés 0/2 282ms 3532 KiB
15 Időlimit túllépés 0/2 270ms 4428 KiB
16 Időlimit túllépés 0/2 257ms 4460 KiB
17 Időlimit túllépés 0/2 266ms 4376 KiB
18 Időlimit túllépés 0/2 241ms 4428 KiB
19 Időlimit túllépés 0/2 273ms 4596 KiB
20 Időlimit túllépés 0/2 282ms 3944 KiB
21 Időlimit túllépés 0/2 277ms 4776 KiB
22 Elfogadva 2/2 71ms 7052 KiB