Pagini recente » Cod sursa (job #330210) | Cod sursa (job #1029572) | Cod sursa (job #2987326) | Cod sursa (job #930208) | Cod sursa (job #973274)
Cod sursa(job #973274)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("secventa.in");
ofstream g("secventa.out");
signed int i,v[500000],k,n,pozmin,bazamax= -30000,m;
signed int baza(int a)
{
m=30000;
for(;a<=i;a++)
if(v[a]<m)
m=v[a];
return m;
}
int main()
{
f>>n>>k;
for(i=0;i<k-1;i++)
f>>v[i];
for(i=k-1;i<n;i++)
{
f>>v[i];
if(v[i]>bazamax)
if(baza(i-k+1)>bazamax)
{
pozmin=i-k+1;
bazamax=m;
}
}
g<<pozmin+1<<' '<<pozmin+k<<' '<<bazamax;
return 0;
}