Pagini recente » Cod sursa (job #145860) | Cod sursa (job #2832109) | Cod sursa (job #2710971) | Cod sursa (job #2667179) | Cod sursa (job #312200)
Cod sursa(job #312200)
#include <stdio.h>
long st,dr,i,n,k,v[500010],a[500010],x,y,max;
int main()
{freopen("secventa.in","r",stdin);freopen("secventa.out","w",stdout);
st=1;dr=0;
scanf("%ld%ld",&n,&k);
for(i=1;i<=n;i++)
{scanf("%ld",&a[i]);
while(st<=dr&&a[v[dr]]>a[i])dr--;
dr++;v[dr]=i;
if(v[st]==i-k)st++;
if(i>=k)
if(a[v[st]]>max){max=a[v[st]];
x=i-k+1;
y=i;
}
}
printf("%ld %ld %ld",x,y,max);
fclose(stdin);fclose(stdout);
return 0;
}