Pagini recente » Cod sursa (job #2713262) | Cod sursa (job #2185921) | Cod sursa (job #616295) | Cod sursa (job #1642968) | Cod sursa (job #1388658)
#include<iostream>
#include<fstream>
using namespace std;
int n,k,a[500050],d[500050],ind;
int main()
{
ifstream fin("secventa.in");
ofstream fout("secventa.out");
int f=0,b=-1,ma=-30001;
fin>>n>>k;
for(int i=0;i<=n;++i)
fin>>a[i];
for(int i=1;i<=n;++i)
{
while((f<=b)&&(a[i]<=a[d[b]]))--b;
++b;
d[b]=i;
if(d[f]==i-k)++f;
if(i>=k&&a[d[f]]>ma){
ma=a[d[f]];
ind=i;
}
}
fout<<ind-k+2<<" "<<ind+1<<" "<<ma;
return 0;
}