210562026-01-12 10:26:30hunzombiFasor (40)cpp17Időlimit túllépés 20/40291ms1268 KiB
#include <bits/stdc++.h>
using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<int> arr(n, 0);
    for (int i=0; i < n; i++) {
        cin >> arr[i];
    }
    for (int i=0; i < n; i++) {
        int left = i - 1, right = i + 1;
        bool good = true;
        while ((left >= 0 || right < n) && left >= i - k && right <= i + k) {
            if (left >= 0 ) {
                if (arr[left] > arr[i]) {
                    good = false;
                }
                left--;
            }
            if (right < n) {
                if (arr[right] > arr[i]) {
                    good = false;
                }
                right++;
            }
        }
        if (good) {
            cout << i + 1 << '\n';
            return 0;
        }
    }
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base20/40
1Elfogadva0/01ms508 KiB
2Elfogadva0/02ms316 KiB
3Elfogadva2/21ms316 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva2/21ms316 KiB
9Elfogadva2/22ms460 KiB
10Elfogadva2/22ms460 KiB
11Elfogadva2/22ms316 KiB
12Elfogadva2/22ms508 KiB
13Időlimit túllépés0/2275ms840 KiB
14Időlimit túllépés0/2277ms820 KiB
15Időlimit túllépés0/2277ms1076 KiB
16Időlimit túllépés0/2277ms1076 KiB
17Időlimit túllépés0/2291ms1268 KiB
18Időlimit túllépés0/2291ms1080 KiB
19Időlimit túllépés0/2291ms1076 KiB
20Időlimit túllépés0/2291ms836 KiB
21Időlimit túllépés0/2284ms1076 KiB
22Időlimit túllépés0/2284ms1076 KiB