| 24815 | 2026-02-15 20:47:25 | AkosVagyokEmbor | Fasor (40) | cpp17 | Forditási hiba |
#include <iostream>
#include <vector>
using namespace std;
vector <int>t, tav;
int n, k;
void be() {
cin >> n >> k;
t.resize(n + 1);
for (int i = 1; i <= n; i++) {
cin >> t[i];
}
}
void nagy() {
for (int i = k + 1; i <= n - k; i++) {
auto it= max_element(t.begin()+1+i-k-1, t.begin() + i + k);
if (*it == t[i]) {
cout << i;
break;
}
}
}
int main()
{
be();
nagy();
}
open /var/local/lib/isolate/433/box/a.out: no such file or directory
main.cpp: In function 'void nagy()':
main.cpp:15:18: error: 'max_element' was not declared in this scope
15 | auto it= max_element(t.begin()+1+i-k-1, t.begin() + i + k);
| ^~~~~~~~~~~