Pagini recente » Cod sursa (job #2057531) | Statistici Mari n (marin) | Cod sursa (job #2432643) | Cod sursa (job #1029037) | Cod sursa (job #3226969)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("secventa.in");
ofstream fout ("secventa.out");
deque <pair<int,int>> d;
int main()
{
int n,x,Max = -999999999,k,st = 0;
fin >> n >> k;
for (int i=1;i<=n;++i){
fin >> x;
while (!d.empty() and i-d.front().second>=k) d.pop_front();
while (!d.empty() and d.back().first>=x) d.pop_back();
d.push_back({x,i});
if (i>=k){
if (Max<=d.front().first){
Max = d.front().first;
st = d.front().second;
}
}
}
fout << st << ' ' << st+k-1 << ' ' << Max;
return 0;
}