Cod sursa(job #889419)
| Utilizator | Data | 24 februarie 2013 15:06:00 | |
|---|---|---|---|
| Problema | Secventa | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include<fstream>
#include<deque>
using namespace std;
ifstream in("secventa.in");
ofstream out("secventa.out");
int final,x,i,n,k,sol=-70000;
deque<pair<int,int> > Q;
int main()
{
in>>n>>k;
for (i=1;i<=n;i++)
{
in>>x;
while (Q.size() && Q.back().first > x)
Q.pop_back();
Q.push_back(make_pair(x,i));
if (i>=k && Q.front().first>sol)
{
sol=Q.front().first;
final=i;
}
if (i-Q.front().second+1==k)
Q.pop_front();
}
out<<final-k+1<<' '<<final<<' '<<sol;
}
