Pagini recente » Cod sursa (job #345694) | Cod sursa (job #3266379) | Cod sursa (job #2251968) | Cod sursa (job #1941399) | Cod sursa (job #3211200)
// #pragma GCC optimize("O3,unroll-loops")
#include <fstream>
#include <iostream>
#include <deque>
#include <limits>
using namespace std;
int fp() {
int ch, t = 1, n = 0;
while ((ch = getchar_unlocked()) && !isdigit(ch) && ch != '-');
if (ch == '-')
t = -1;
if (isdigit(ch))
n = ch - '0';
while ((ch = getchar_unlocked()) && isdigit(ch))
n = n * 10 + ch - '0';
return t * n;
}
int main() {
freopen("secventa.in", "r", stdin);
ofstream g("secventa.out");
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n = fp(), k = fp(), baza = numeric_limits<int>::min(), j = -1;
deque<pair<int, int>> Q;
for (int i = 1, x; i <= n; ++i) {
x = fp();
while (!Q.empty() && Q.back().first > x)
Q.pop_back();
Q.emplace_back(x, i);
if (!Q.empty() && Q.front().second == i - k)
Q.pop_front();
if (!Q.empty() && i >= k && Q.front().first > baza) {
baza = Q.front().first;
j = i;
}
}
g << j - k + 1 << ' ' << j << ' ' << baza << '\n';
}