Pagini recente » Profil NuSuntRoman | Profil Justin-_-126 | Istoria paginii runda/c1/clasament | Cod sursa (job #2313364) | Cod sursa (job #1833879)
#include <cstdio>
#include <deque>
using namespace std;
const int INF=1e9;
deque<int> q;
int v[500010];
int main()
{
freopen("secventa.in","r",stdin);
freopen("secventa.out","w",stdout);
int n,k,a,b,sol=-INF;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
scanf("%d",&v[i]);
for(int i=1;i<=n;i++)
{
if(q.front()==i-k) q.pop_front();
while(!q.empty() && v[q.back()]>=v[i]) q.pop_back();
q.push_back(i);
if(i>=k) if(v[q.front()]>sol) {sol=v[q.front()];a=i-k+1;b=i;}
}
printf("%d %d %d",a,b,sol);
return 0;
}