Cod sursa(job #2281278)
| Utilizator | Data | 11 noiembrie 2018 20:58:20 | |
|---|---|---|---|
| Problema | Secventa | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <fstream>
std::ifstream cin("secventa.in");
std::ofstream cout("secventa.out");
#define maxn 500005
#define inf -55555
int v[maxn],dequ[maxn],n,k;
int main()
{
int fr=1,bk=0,ind,sol=inf;
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>v[i];
while(fr<=bk&&v[i]<v[dequ[bk]])
bk--;
dequ[++bk]=i;
if(i-k==dequ[fr])
fr++;
if(i>=k&&sol<v[dequ[fr]])
sol=v[dequ[fr]],ind=dequ[fr];
}
while(sol<=v[ind]&&ind>0)
ind--;
ind++;
while(sol<=v[ind]&&ind<=n)
cout<<v[ind++]<<' ';
return 0;
}
