#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
struct custromer{
int process_time ,leave_time=0;
};
int N,M,K,Q;//N窗口,M每个窗口人数,K总人数,Q查询数
custromer c[1001];
int main()
{
int i,j,cursor=1;
cin>>N>>M>>K>>Q;
queue<int>q[N];
for(i=1;i<=K;i++)cin>>c[i].process_time;
for(int Time=480;Time<1020;Time++){
for(i=0;i<N;i++){
if(q[i].size()){
j=q[i].front();
if(c[j].leave_time==Time){
q[i].pop();
}
}
}
//送客
for(j=1;j<=M;j++){
for(i=0;i<N;i++){
if(q[i].size()<j){
if(cursor<=K){
q[i].push(cursor);
cursor++;
}
}
}
}
//入队
for(i=0;i<N;i++){
if(q[i].size()){
j=q[i].front();
if(c[j].leave_time==0){
c[j].leave_time=Time+c[j].process_time;
}
}
}
//迎客
}
while(Q--){
cin>>i;
if(c[i].leave_time==0){
cout<<"Sorry\n";
}
else{
printf("%02d:%02d\n",c[i].leave_time/60,c[i].leave_time%60);
}
}
}
1014 Waiting in Line
最新推荐文章于 2024-10-31 20:10:41 发布