Pagini recente » Cod sursa (job #933028) | Cod sursa (job #2305136) | Cod sursa (job #3265545) | Cod sursa (job #31000) | Cod sursa (job #1593035)
#include <iostream>
#include <fstream>
using namespace std;
int n,k,v[100],i,mx=-1,mn,poz1,poz2,j;
int main()
{
ifstream f("secventa.in");
ofstream g("secventa.out");
f>>n>>k;
for(i=1;i<=n;i++) f>>v[i];
for(i=1;i<=n-k+1;i++)
{
mn=9999;
for(j=i;j<=i+k-1;j++)
if(v[i]<mn) mn=v[i];
if(mn>mx) {mx=mn;poz1=i;poz2=i+k-1;}
}
g<<poz1<<" "<<poz2<<" "<<mx;
f.close();
g.close();
return 0;
}