207452026-01-08 18:33:25KoszorusBlankaFasor (40)cpp17Wrong answer 38/4071ms1196 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector <int> H(N+1);
    for (int i = 1; i <= N; i++) { cin >> H[i]; }

    int i = 1;
    bool talalt = true;
    while (i < N) {
        talalt = true;
        for (int j = i+1; j <= i+K && j <= N; j++) {
            if (H[j] > H[i]) {
                talalt = false;
                i = j;
                break;
            }
        }
        if (talalt) {
            for (int j = i-1; i >= i-K && j >= 1; j--) {
                if (H[j] > H[i]) {
                    talalt = false;
                    i = j;
                    break;
                }
            }
        }
        if (talalt) { cout << i; break; }
    }

    if (!talalt) {cout << -1; }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base38/40
1Accepted0/01ms316 KiB
2Accepted0/04ms500 KiB
3Accepted2/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Accepted2/21ms508 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/22ms316 KiB
9Accepted2/24ms316 KiB
10Accepted2/24ms432 KiB
11Accepted2/24ms316 KiB
12Accepted2/23ms560 KiB
13Accepted2/237ms820 KiB
14Accepted2/232ms564 KiB
15Accepted2/256ms1076 KiB
16Accepted2/264ms1196 KiB
17Accepted2/271ms1192 KiB
18Accepted2/271ms1076 KiB
19Accepted2/270ms1076 KiB
20Accepted2/220ms564 KiB
21Accepted2/256ms1076 KiB
22Accepted2/271ms1076 KiB