Cod sursa(job #519355)
| Utilizator | Data | 5 ianuarie 2011 08:42:50 | |
|---|---|---|---|
| Problema | Secventa | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<fstream.h>
#define NMAX 500005
int p, u, i, a[NMAX], n, d[NMAX], max=-NMAX, k, pmax;
int main()
{
ifstream f("secventa.in");
ofstream g("secventa.out");
f>>n>>k;
p=1;
for (i=1; i<=n; ++i)
{
f>>a[i];
while (a[i]<d[u] && u>p) --u;
d[++u]=i;
if (d[p]==i-k) ++p;
if (max<a[d[p]])
{
max=a[d[p]];
pmax=d[p];
}
}
g<<pmax<<" "<<pmax+k-1<<" "<<max<<"\n";
f.close();
g.close();
return 0;
}