162622025-04-16 17:58:11algoproFasor (40)cpp17Accepted 40/4023ms1132 KiB
// UUID: 6d08479f-d2e6-48ea-aa98-ebab3dac200f
#include <bits/stdc++.h>

typedef unsigned long long int ulli;
typedef long long int lli;

using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for(int &h : H) cin >> h;
    int h = 0;
    bool u;
    while(h < N) {
        u = false;
        for(int i = h + 1; i <= min(h + K, N); ++i) {
            if(H[h] < H[i]) {
                h = i;
                u = true;
                break;
            }
        }
        if(!u) break;
    }
    cout << h + 1 << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms316 KiB
2Accepted0/02ms316 KiB
3Accepted2/21ms508 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms548 KiB
8Accepted2/21ms316 KiB
9Accepted2/22ms316 KiB
10Accepted2/22ms316 KiB
11Accepted2/22ms508 KiB
12Accepted2/22ms508 KiB
13Accepted2/212ms820 KiB
14Accepted2/210ms572 KiB
15Accepted2/218ms1132 KiB
16Accepted2/220ms1076 KiB
17Accepted2/221ms1076 KiB
18Accepted2/223ms1076 KiB
19Accepted2/221ms1076 KiB
20Accepted2/28ms820 KiB
21Accepted2/218ms1076 KiB
22Accepted2/223ms1076 KiB