178712025-09-20 11:52:31algoproFasor (40)cpp17Runtime error 38/4074ms1168 KiB
// UUID: d978e55d-5321-4218-9c98-5e7dac66c183
#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/04ms328 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/22ms316 KiB
9Accepted2/24ms316 KiB
10Accepted2/24ms316 KiB
11Accepted2/24ms508 KiB
12Accepted2/23ms640 KiB
13Accepted2/237ms556 KiB
14Runtime error0/234ms728 KiB
15Accepted2/257ms1168 KiB
16Accepted2/267ms948 KiB
17Accepted2/272ms1068 KiB
18Accepted2/274ms932 KiB
19Accepted2/272ms1076 KiB
20Accepted2/221ms564 KiB
21Accepted2/259ms972 KiB
22Accepted2/272ms956 KiB