Pagini recente » Cod sursa (job #533375) | Cod sursa (job #757909) | Cod sursa (job #1043310) | Cod sursa (job #163455) | Cod sursa (job #919217)
Cod sursa(job #919217)
#include<cstdio>
#include<deque>
#include<fstream>
#define nmax 500010
using namespace std;
deque<int>q;
int n,k,i,x[nmax],crt,sol=-30010;
int main()
{
//freopen("secventa.in","r",stdin);
//freopen("secventa.out","w",stdout);
//scanf("%d%d", &n, &k);
ifstream fin("secventa.in");
ofstream fout("secventa.out");
fin>>n>>k;
for(i=1;i<=n;++i)/*scanf("%d", &x[i]);*/fin>>x[i];
for(i=1;i<=n;i++)
{
while(q.size()&&x[q.back()]>=x[i])
q.pop_back();
q.push_back(i);
if(q.front()==i-k)
q.pop_front();
if(i>=k&&x[q.front()]>sol)
{
sol=x[q.front()];
crt=i;
}
}
//printf("%d %d %d ", crt-k+1, crt, sol);
fout<<crt-k+1<<' '<<crt<<' '<<sol<<'\n';
return 0;
}