Cod sursa(job #380667)
Utilizator | Data | 7 ianuarie 2010 11:20:48 | |
---|---|---|---|
Problema | Secventa | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.13 kb |
#include <iostream.h>
#include <fstream.h>
int v[500000];
fstream f("secventa.in",ios::in);
fstream g("secventa.out",ios::out);
void citire(long int n)
{
for(long int i=0;i<n;i++)
f>>v[i];
}
void secventa(long int n,long int k)
{
long int poz[3],aux[2];
int max=-32000,min=32000;
for(long int i=0;i<n-k;i++)
{
aux[0]=i;
aux[1]=k+i;
for(long int j=i;j<k+i;j++)
if(v[j]<min)
{
min=v[j];
poz[0]=j;
}
i=poz[0]-1;
if(min>max)
{
max=min;
poz[1]=aux[0];
poz[2]=aux[1];
poz[3]=poz[0];
}
}
g<<v[poz[1]]<<" "<<v[poz[2]]<<" "<<v[poz[3]];
}
int main()
{
long int n,k;
f>>n;
f>>k;
citire(n);
secventa(n,k);
return 0;
}