#include<bits/stdc++.h>
using namespace std;
const int mxn=1e6+10;
const int INF=0x3f3f3f3f;
stack<int> box;
queue<int> p,t;
int main()
{
int n,m,k;
cin>>n>>m>>k;
for(int a,i=1;i<=n;i++)
cin>>a,p.push(a);
while(p.size()||box.size())
{
t.push(101);//使松枝放下第一个松针
while(t.size()<=k)
{
if(box.size()&&box.top()<=t.back())
t.push(box.top()),box.pop();
//如果盒子不空,且待取元素符合题意
else if(p.size()&&p.front()<=t.back())
t.push(p.front()),p.pop();
//推送器不为空,且待取元素符合题意
else if(p.size()&&box.size()<m)
box.push(p.front()),p.pop();
//将不合题意元素放置到盒子中
else break;
}
t.pop();//去除第一个无用元素
cout<<t.front();t.pop();
while(t.size())
cout<<" "<<t.front(),t.pop();
cout<<endl;
}
return 0;
}
天梯赛 L2-041 插松枝
最新推荐文章于 2024-01-07 19:35:43 发布