Cod sursa(job #2294289)
| Utilizator | Data | 2 decembrie 2018 10:09:01 | |
|---|---|---|---|
| Problema | Secventa | Scor | 80 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("secventa.in");
ofstream fout("secventa.out");
int t[500005],q[500005];
long long i,j,p,u,m=-1000000000,n,x,y,k;
int main()
{
fin>>n>>k; p=1;u=0;
for (i=1;i<=n;i++)
{
fin>>t[i];
while (p<=u && t[q[u]]>=t[i]) u--;
u++;
q[u]=i;
if (q[p]==i-k) p++;
if (i>=k)
if (t[q[p]]>m) {m=t[q[p]]; x=i;}
}
fout<<x-k+1<<" "<<x<<" "<<m;
return 0;
}
