| 20515 | 2026-01-07 15:42:34 | ProgramozoRoka | Fasor (40) | cpp17 | Forditási hiba |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
vector<int> h(200000);
cin>>n>>k;
for(int i=0;i<n;++i)
{
cin>>h[i];
}
for(int i=0;i<n;++i)
{
int r=i+k+1;
if(r>=n) r=n-1;
if(h[i]>=*max_element(h.begin()+i,h.begin()+r))
{
cout<<i+1;
return 0;
}
else
i=max_element(h.begin()+l,h.begin()+r)-h.begin()-1;
}
cout<<-1;
return 0;
}
open /var/local/lib/isolate/428/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:24:37: error: 'l' was not declared in this scope
24 | i=max_element(h.begin()+l,h.begin()+r)-h.begin()-1;
| ^