Pagini recente » Cod sursa (job #436179) | Cod sursa (job #552160) | Cod sursa (job #446404) | Cod sursa (job #2323665) | Cod sursa (job #2502612)
#include <bits/stdc++.h>
using namespace std;
int n,k,nr,poz,baza,poz1;
deque < pair <int,int> > chestie;
int main () {
freopen("secventa.in","r",stdin);
freopen("secventa.out","w",stdout);
scanf("%d%d%d", &n, &k, &nr);
chestie.push_back(make_pair(1,nr));
for(int i=2;i<=n;++i) {
scanf("%d", &nr);
while(!chestie.empty() && chestie.front().second>nr)
chestie.pop_back();
chestie.push_back(make_pair(i,nr));
while(i-chestie.front().first+1>=k) {
if(chestie.front().second>baza)
baza=chestie.front().second,poz=chestie.front().first,poz1=i;
chestie.pop_front();
}
}
printf("%d %d %d", poz, poz1, baza);
return 0;
}