Pagini recente » Cod sursa (job #1862186) | Cod sursa (job #2370146) | Cod sursa (job #2810031) | Cod sursa (job #2852607) | Cod sursa (job #3226818)
#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;
}