97352024-03-04 15:58:11ct72Fasor (40)cpp17Accepted 40/4072ms5796 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<n); 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
base40/40
1Accepted0/03ms1960 KiB
2Accepted0/04ms2384 KiB
3Accepted2/23ms2536 KiB
4Accepted2/23ms2628 KiB
5Accepted2/23ms2868 KiB
6Accepted2/23ms3052 KiB
7Accepted2/23ms3140 KiB
8Accepted2/23ms3144 KiB
9Accepted2/24ms3188 KiB
10Accepted2/26ms3168 KiB
11Accepted2/26ms3436 KiB
12Accepted2/24ms3756 KiB
13Accepted2/237ms4440 KiB
14Accepted2/234ms4216 KiB
15Accepted2/259ms4988 KiB
16Accepted2/267ms5076 KiB
17Accepted2/272ms5076 KiB
18Accepted2/272ms5200 KiB
19Accepted2/272ms5284 KiB
20Accepted2/223ms4912 KiB
21Accepted2/259ms5428 KiB
22Accepted2/271ms5796 KiB