CF83B 题解
纯属队列训练题
这题其实说的很明白,就是让你在
你们最爱的代码:
#include<bits/stdc++.h>
using namespace std;
long long n,k,x,s;
queue<long long>que;
queue<long long>hao;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;++i)
{
cin>>x;
que.push(x);//输入
hao.push(i);//编号
}
for(int i=1;i<=k;++i)
{
if(que.empty())//若队列为空
{
cout<<-1<<endl;//直接带走
return 0;
}
x=que.front(),s=hao.front();
que.pop(),hao.pop();//先让第一个数“退休”
if(x-1>0)//若还没有到退休的时候(打个比方)
que.push(x),hao.push(s);//快点回来上班儿
}
while(!hao.empty())//输出
{
cout<<hao.front()<<' ';
hao.pop();
}
return 0;
}
管理员求过!!!!!!!