Cod sursa(job #714977)

Utilizator mening12001Andrei Geogescu mening12001 Data 16 martie 2012 13:38:02
Problema Secventa Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<fstream>
#include<set>
using namespace std;

int main()
{ifstream f("secventa.in");
ofstream h("secventa.out");
int n,m,a[100],i,max,j,x,y;
multiset<int> v;
multiset<int>::iterator it;
f>>n>>m;
for(i=1;i<=n;i++)
f>>a[i];
for(i=1;i<=m;i++)
v.insert(a[i]);
max=*v.begin();
x=1;
y=m;
for(i=2;i<=n-m+1;i++)
{v.erase(a[i-1]);
for(j=i;j<i+m;j++)
v.insert(a[j]);
if(*v.begin()>max)
{max=*v.begin();
x=i;
y=i+m-1;}}

h<<x<<" "<<y<<" "<<max;
	
return 0;}