| 21854 | 2026-01-14 09:28:27 | BDavid5616 | Fasor (40) | cpp17 | Compilation error |
#include <fstream>
using namespace std;
int main()
{int i,q,db,s,t,b,c=1,a[200000],n,k;
cin>>n>>k;
for(i=0;i<n;i++){
cin>>a[i];
}
b=-1;
for(i=0;i<n;i++){q=i+k;t=1;db=1;
for(s=i+1;s<=q;s++){
if(a[i]<a[s])t=0;
}
if(i>=k){q=i-k;
for(s=i-1;s>=q;s--){
if(a[i]<a[s])db=0;
}
}
if(db==1 && t==1 && c==1){b=i+1;c=0;}
}cout<<b;
return 0;
}
open /var/local/lib/isolate/417/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:6:5: error: 'cin' was not declared in this scope
6 | cin>>n>>k;
| ^~~
main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
1 | #include <fstream>
+++ |+#include <iostream>
2 | using namespace std;
main.cpp:21:6: error: 'cout' was not declared in this scope
21 | }cout<<b;
| ^~~~
main.cpp:21:6: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?