125072024-12-20 22:41:58CsongiFasor (40)cpp17Time limit exceeded 22/40298ms1268 KiB
#include <bits/stdc++.h>
//#define ll long long
using namespace std;

int szomszedok(const vector<int> &v, const int &k, const int &n)
{
    for (int i = 0; i < n; i++)
    {
        bool talalt = true;
        for (int j = max(0, i-k); j <= min(n-1,i+k); j++)
        {
            if (j!=i && v[i]<v[j])
            {
                talalt = false;
                break;
            }
        }
        if (talalt) return i;
        
    }
    return -2;
}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n,k,x; cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        v[i] = x;
    }

    cout << szomszedok(v,k,n)+1 << endl;

    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/01ms320 KiB
2Accepted0/02ms320 KiB
3Accepted2/21ms508 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms388 KiB
7Accepted2/21ms432 KiB
8Accepted2/21ms324 KiB
9Accepted2/22ms508 KiB
10Accepted2/22ms320 KiB
11Accepted2/22ms320 KiB
12Accepted2/22ms420 KiB
13Time limit exceeded0/2298ms824 KiB
14Time limit exceeded0/2298ms824 KiB
15Time limit exceeded0/2298ms1080 KiB
16Time limit exceeded0/2298ms1080 KiB
17Time limit exceeded0/2284ms1080 KiB
18Time limit exceeded0/2287ms1080 KiB
19Time limit exceeded0/2287ms1260 KiB
20Time limit exceeded0/2287ms824 KiB
21Time limit exceeded0/2273ms1268 KiB
22Accepted2/224ms1080 KiB