Pagini recente » Cod sursa (job #1889003) | Cod sursa (job #704598) | Cod sursa (job #1834671) | Cod sursa (job #1991354) | Cod sursa (job #2439530)
#include <fstream>
#include <deque>
#define val first
#define poz second
using namespace std;
ifstream fin("secventa.in");
ofstream fout("secventa.out");
int n,i,k,x,mx=-30001,i1,i2;
deque <pair<int,int> > deq;
int main(){
fin>>n>>k;
for(i=1;i<=n;i++){
fin>>x;
while(deq.size() && x<deq.back().val)
deq.pop_back();
deq.push_back(make_pair(x,i));
if(i-deq.front().poz==k){
if(deq.front().val>mx)
mx=deq.front().val,i1=deq.front().poz,i2=i;
deq.pop_front();
}
}
if(deq.front().val>mx)
mx=deq.front().val,i1=deq.front().poz,i2=n;
fout<<i1<<" "<<i2<<" "<<mx;
return 0;
}