Pagini recente » Cod sursa (job #606819) | Cod sursa (job #559042) | Cod sursa (job #841012) | Cod sursa (job #2999825) | Cod sursa (job #2281305)
#include <fstream>
std::ifstream cin("secventa.in");
std::ofstream cout("secventa.out");
#define maxn 500005
int v[maxn],dequ[maxn],n,k,sol=-55555,ind;
int main()
{
int fr=1,bk=0,i;
cin>>n>>k;
for(i=1;i<=n;i++){
cin>>v[i];
while(fr<=bk&&v[i]<v[dequ[bk]])
bk--;
dequ[++bk]=i;
if(i-k==dequ[fr])
fr++;
if(i>=k&&sol<v[dequ[fr]])
sol=v[dequ[fr]],ind=dequ[bk];
}
cout<<ind-k+1<<' '<<ind<<' '<<sol;
return 0;
}