gzy0215 @ 2023-08-14 08:39:24
#include<bits/stdc++.h>
using namespace std;
std::deque<unsigned long long int> a;
int main()
{
int m,n,e[500001],d[500001],h[500001],f[500001],g=0;
cin>>m>>n;
for(int i=1;i<=m;i++)
{
cin>>e[i];
a.push_front(e[i]);
}
for(int i=1;i<=m;i++)
{
if(i+n<=m)
{
for(int j=i+n;j<=m;j++)
{
g=a.front();
a.pop_front();
a.push_back(g);
g=0;
}
}
for(int o=1;o<=n;o++)
{
h[i]=a.front();
}
for(int l=1;l<=n;l++)
{
if(h[l]>h[l+1]&&h[l]>h[0])
{
h[0]=h[l];
h[n+2]=h[l+1];
}
}
for(int s=1;s<=n;s++)
{
a.push_back(h[s]);
}
e[i]=h[0];
d[i]=h[n+2];
}
for(int i=1;i<=m-n+1;i++)
{
cout<<e[i]<<" ";
}
cout<<endl;
for(int i=1;i<=m-n+1;i++)
{
cout<<d[i]<<" ";
}
return 0;
}