Cod sursa(job #1452327)
| Utilizator | Data | 20 iunie 2015 16:12:59 | |
|---|---|---|---|
| Problema | Secventa | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <bits/stdc++.h>
using namespace std;
int N,K,Sol = -100000,L,X;
deque < pair<int,int> > D;
int main()
{
freopen("secventa.in","r",stdin);
freopen("secventa.out","w",stdout);
scanf("%d%d",&N,&K);
for (int i = 1;i <= N;i++)
{
scanf("%d",&X);
while (!D.empty() && D.back().first > X)
D.pop_back();
D.push_back(make_pair(X,i));
if (D.front().second == i - K)
D.pop_front();
if (Sol < D.front().first)
Sol = D.front().first,L = i - K + 1;
}
printf("%d %d %d\n",L,L + K - 1,Sol);
return 0;
}
