Pagini recente » Cod sursa (job #727942) | Cod sursa (job #2699641) | Cod sursa (job #48393) | Cod sursa (job #1479437) | Cod sursa (job #370494)
Cod sursa(job #370494)
#include <cstdio>
//#include <deque>
int v[500000];
int s[500000];
int main(){
freopen("secventa.in","rt",stdin);
freopen("secventa.out","wt",stdout);
//std::deque<int> x;
int i,n,k;
int pos=15,max=-1000000;
scanf("%d%d",&n,&k);
int front=1,back=0;
for(i=0;i<n;i++){
scanf("%d",&v[i]);
/*while(!x.empty()&&v[i]<x.back())x.pop_back();
x.push_back(v[i]);
*/
while(front<=back&&v[i]<v[s[back]])back--;
s[back]=i;
++back;
/*if(i>=k-1){
if(v[i-k]==x.front())
x.pop_front();
if(x.front()>max){
pos=i;
max=x.front();
}
}*/
if(i>=k-1){
if(i-s[Front]+1==k)
front++;
if(v[s[front]]>max){
pos=i;
max=s[front];
}
}
}
printf("%d %d %d",pos+2-k,pos+1,max);
return 0;
}