36262023-03-01 12:08:27UnluckYFasor (40)cpp11Runtime error 22/40109ms19632 KiB
#include <bits/stdc++.h>


using namespace std;


int main(){



    int n, k; cin >> n >> k;

    bool m = false;

    vector<int> v;

    for (int i = 0; i < n; i++){

        int x; cin >> x; v.push_back(x);


    }

    multiset<int> s;

    for (int i = 0; i < k; i++){
        s.insert(v[i]);
    }

    for (int i = 0; i <= k; i++){
        if (i+k < n) s.insert(v[i+k]);
        if (*s.rbegin() == v[i]){cout << i+1;  m = true; break;}
    }


    if (!m){for (int i = k+1; i < n; i++){
        if (i+k < n) s.insert(v[i+k]);
        s.erase(s.find(i-k));
        if (*s.rbegin() == v[i]){cout << i+1; m = true; break;}
    }}


    if (!m) cout << -1;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/03ms1956 KiB
2Runtime error0/06ms2544 KiB
3Accepted2/23ms2292 KiB
4Runtime error0/23ms2560 KiB
5Accepted2/23ms2488 KiB
6Runtime error0/23ms2800 KiB
7Accepted2/23ms2880 KiB
8Runtime error0/24ms3208 KiB
9Accepted2/26ms3532 KiB
10Runtime error0/26ms3608 KiB
11Runtime error0/26ms3552 KiB
12Accepted2/24ms3700 KiB
13Runtime error0/250ms9316 KiB
14Runtime error0/270ms16752 KiB
15Accepted2/2100ms17596 KiB
16Accepted2/297ms14276 KiB
17Accepted2/2109ms16232 KiB
18Runtime error0/292ms12048 KiB
19Runtime error0/276ms7216 KiB
20Accepted2/252ms14044 KiB
21Accepted2/2108ms19632 KiB
22Accepted2/2101ms13716 KiB