Mai intai trebuie sa te autentifici.
Cod sursa(job #284065)
| Utilizator | Data | 20 martie 2009 22:28:51 | |
|---|---|---|---|
| Problema | Secventa | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <stdio.h>
int v[500001],deque[500001];
int n,k,i,dr,st=1,mmax=-50000,xmax,ymax;
int main ()
{
freopen ("secventa.in","r",stdin);
freopen ("secventa.out","w",stdout);
scanf ("%d %d",&n,&k);
for (i=1;i<=n;i++){
scanf ("%d",&v[i]);
while (v[i]<v[deque[dr]] && st<=dr) dr--;
deque[++dr]=i;
if (deque[st]==i-k) st++;
if (i>=k && mmax<v[deque[st]]){
mmax=v[deque[st]];
ymax=i;
xmax=i-k+1;
}
}
printf ("%d %d %d",xmax,ymax,mmax);
return 0;
}
