Pagini recente » Cod sursa (job #2246774) | Cod sursa (job #2070176) | Cod sursa (job #1292259) | preONI 2006 | Cod sursa (job #1452340)
#include <bits/stdc++.h>
#define INF -1000000
#define Dim 1000000
using namespace std;
int N,K,Sol = INF,L,X;
char Buff[Dim];
int it = Dim - 1;
deque < pair<int,int> > D;
void Read(int &X)
{
X = 0;
int sgn = 1;
while ((Buff[it] < '0' || Buff[it] > '9') && Buff[it] !='-')
if (++it == Dim)
fread(Buff,1,Dim,stdin),it = 0;
while ('0' <= Buff[it] && Buff[it] <= '9' || Buff[it] == '-')
{
if (Buff[it] == '-')
sgn = -1;
else
X = X*10 + Buff[it] - '0';
if (++it == Dim)
fread(Buff,1,Dim,stdin),it = 0;
}
X *= sgn;
}
int main()
{
freopen("secventa.in","r",stdin);
freopen("secventa.out","w",stdout);
Read(N);
Read(K);
for (int i = 1;i <= N;i++)
{
Read(X);
while (!D.empty() && D.back().first > X)
D.pop_back();
D.push_back(make_pair(X,i));
if (i < K) continue;
if (D.front().second == i - K)
D.pop_front();
if (Sol < D.front().first)
Sol = D.front().first,L = i - K + 1;
}
printf("%d %d %d\n",L,L + K - 1,Sol);
return 0;
}