69992023-12-25 10:29:41MagyarKendeSZLGFasor (40)cpp17Time limit exceeded 22/40277ms4648 KiB
#include <iostream>
#include <vector>
using namespace std;
#define speed cin.tie(0); ios::sync_with_stdio(0)

int N, K;
vector<int> v;

bool locally_high(int i) {
    for (int j = 1; j <= K; j++) {
        if ((i - j >= 0 ? v[i] < v[i - j] : 0) || (i + j < N ? v[i] < v[i + j] : 0)) 
            return 0;
    }
    return 1;
}

int main() {
    speed;

    cin >> N >> K;
    v.resize(N);
    
    for (int i = 0; i < N; i++) cin >> v[i];
    for (int i = 0; i < N; i++) {
        if (locally_high(i)) {
            cout << i + 1;
            exit(0);
        }
    }

    cout << -1;
}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/03ms1892 KiB
2Accepted0/04ms2296 KiB
3Accepted2/23ms2336 KiB
4Accepted2/23ms2376 KiB
5Accepted2/23ms2512 KiB
6Accepted2/23ms2716 KiB
7Accepted2/23ms2808 KiB
8Accepted2/23ms2832 KiB
9Accepted2/24ms2860 KiB
10Accepted2/24ms2856 KiB
11Accepted2/24ms2856 KiB
12Accepted2/24ms3112 KiB
13Time limit exceeded0/2275ms2720 KiB
14Time limit exceeded0/2277ms2592 KiB
15Time limit exceeded0/2270ms3080 KiB
16Time limit exceeded0/2246ms3148 KiB
17Time limit exceeded0/2261ms3212 KiB
18Time limit exceeded0/2266ms3156 KiB
19Time limit exceeded0/2254ms3084 KiB
20Time limit exceeded0/2261ms3012 KiB
21Time limit exceeded0/2273ms3284 KiB
22Accepted2/228ms4648 KiB