27932023-01-25 09:48:22tamasmarkFasor (40)cpp17Time limit exceeded 14/40300ms7052 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
SubtaskSumTestVerdictTimeMemory
base14/40
1Accepted0/03ms1744 KiB
2Accepted0/04ms2120 KiB
3Time limit exceeded0/2231ms2092 KiB
4Wrong answer0/22ms2320 KiB
5Time limit exceeded0/2300ms2372 KiB
6Accepted2/22ms2524 KiB
7Accepted2/22ms2748 KiB
8Accepted2/23ms2980 KiB
9Accepted2/24ms3092 KiB
10Accepted2/26ms3384 KiB
11Time limit exceeded0/2300ms3300 KiB
12Accepted2/24ms3592 KiB
13Time limit exceeded0/2300ms3400 KiB
14Time limit exceeded0/2282ms3532 KiB
15Time limit exceeded0/2270ms4428 KiB
16Time limit exceeded0/2257ms4460 KiB
17Time limit exceeded0/2266ms4376 KiB
18Time limit exceeded0/2241ms4428 KiB
19Time limit exceeded0/2273ms4596 KiB
20Time limit exceeded0/2282ms3944 KiB
21Time limit exceeded0/2277ms4776 KiB
22Accepted2/271ms7052 KiB