97342024-03-04 15:56:00ct72Fasor (40)cpp17Runtime error 38/4081ms5596 KiB
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0;i<n;i++) {
        cin >> v[i];
    }
    int i=0,s=-1;
    while(i!=s && i<n) {
        s=i;
        for (int j = i + 1; j <= i + k; j++) {
            if (v[j] > v[i]) {
                s = j;
                break;
            }

        }
        if(s!=i)
        {
            i=s;
            s=-1;
        }
    }
    if(i>=n)
    {
        cout<<"-1";
    }
    else
    cout << i+1;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base38/40
1Accepted0/03ms1812 KiB
2Accepted0/06ms2228 KiB
3Accepted2/23ms2268 KiB
4Accepted2/23ms2476 KiB
5Accepted2/23ms2724 KiB
6Accepted2/23ms2940 KiB
7Accepted2/23ms3156 KiB
8Accepted2/23ms3240 KiB
9Accepted2/26ms3240 KiB
10Accepted2/26ms3504 KiB
11Accepted2/26ms3448 KiB
12Accepted2/24ms3792 KiB
13Accepted2/241ms4432 KiB
14Runtime error0/237ms4356 KiB
15Accepted2/264ms4972 KiB
16Accepted2/271ms5172 KiB
17Accepted2/281ms5240 KiB
18Accepted2/279ms5240 KiB
19Accepted2/279ms5332 KiB
20Accepted2/225ms4808 KiB
21Accepted2/263ms5448 KiB
22Accepted2/278ms5596 KiB