178692025-09-20 11:23:04algoproFasor (40)cpp17Runtime error 38/4074ms1180 KiB
// UUID: ad66f51d-5d64-4efe-bc7f-4724d58e5361
#include <bits/stdc++.h>
using namespace std;
int N, K;
int H[200001];
int fugg(int, int);

int main() {
	
    cin>>N>>K;
    for(int i=1; i<=N; i++) cin>>H[i];
    cout<<fugg(1, 1-K);

}
int fugg(int meghivottfa, int elozofa)
{
    int magassag=H[meghivottfa];
    int maxi=0, maxis;
    for(int i=elozofa+K+1; i<=meghivottfa+K; i++)
    {
        if(maxi<H[i])
        {
            maxi=H[i];
            maxis=i;
        }
    }
    if(maxi<=magassag) return meghivottfa;
    return(fugg(maxis, meghivottfa));
}
SubtaskSumTestVerdictTimeMemory
base38/40
1Accepted0/01ms316 KiB
2Accepted0/04ms500 KiB
3Accepted2/21ms500 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/22ms316 KiB
9Accepted2/24ms364 KiB
10Accepted2/24ms316 KiB
11Accepted2/24ms412 KiB
12Accepted2/23ms316 KiB
13Accepted2/237ms792 KiB
14Runtime error0/234ms740 KiB
15Accepted2/257ms1004 KiB
16Accepted2/267ms1072 KiB
17Accepted2/274ms1076 KiB
18Accepted2/274ms1180 KiB
19Accepted2/272ms1008 KiB
20Accepted2/221ms564 KiB
21Accepted2/259ms1136 KiB
22Accepted2/272ms1084 KiB