Pagini recente » Cod sursa (job #2287878) | Cod sursa (job #793195) | Cod sursa (job #1985393) | Cod sursa (job #2809447) | Cod sursa (job #778479)
Cod sursa(job #778479)
using namespace std;
#include<fstream>
#include<deque>
#include<algorithm>
#define inF "secventa.in"
#define outF "secventa.out"
#define INF 32000
int main ()
{
int n,k,i=0,x,min=INF,inf ,sup;
deque<int>v;
pair<int,pair<int,int> > rez1;
rez1.first=INF;
ifstream f(inF);
f>>n>>k;
rez1.second.first=inf=1;
rez1.second.second=sup=k;
for(i=1;i<=k;i++)
{
f>>x;
if(x<min)
min=x;
while(x<=*v.end() && v.size()!=1)
v.pop_back();
v.push_back(x);
}
i=k;
rez1.first=min;
while(i!=n)
{
f>>x;
v.pop_front();
while(x<=*v.end() &&v.size()!=1)
v.pop_back();
v.push_back(x);
min=*min_element(v.begin(),v.end());
i++,inf++,sup++;
if(min>rez1.first)
{
rez1.first=min;
rez1.second.first=inf;
rez1.second.second=sup;
}
}
f.close();
ofstream g(outF);
g<<rez1.second.first<<" "<<rez1.second.second<<" "<<rez1.first;
g.close();
return 0;
}