Cod sursa(job #1002275)
| Utilizator | Data | 27 septembrie 2013 11:10:18 | |
|---|---|---|---|
| Problema | Secventa | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include<fstream>
#include<deque>
using namespace std;
ifstream f("secventa.in");
ofstream g("secventa.out");
int u,maxi=-99999999,i,n,k,x,a[500001];
long long s;
deque<int> d;
int main()
{
f>>n>>k;
for(i=1;i<=n;++i)
f>>a[i];
for(i=1;i<=n;++i)
{
while(!d.empty()&&a[d.back()]>a[i])
d.pop_back();
d.push_back(i);
if(d.front()==i-k)
d.pop_front();
if(i>=k&&a[d.front()]>maxi)
{
maxi=a[d.front()];
u=i;
}
}
g<<u-k+1<<" "<<u<<" "<<maxi<<'\n';
return 0;
}
