Cod sursa(job #312190)
Utilizator | Data | 5 mai 2009 12:49:09 | |
---|---|---|---|
Problema | Secventa | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <stdio.h>
long st,dr,i,n,k,v[500010],a[500010],x,y,max;
int main()
{freopen("deque.in","r",stdin);freopen("deque.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(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;
}