📄 2424.txt
字号:
//nclude"iostream.h"
#include"queue"
#include"stdio.h"
using namespace std;
struct node
{
int time;
int dinners;
};
int a[3],ans;
queue<node> have[3];
bool init()
{
char c,t;
int u[3],t1,t2,i;
node nd,nd1;
//cin>>a[0]>>a[1]>>a[2];
scanf("%d%d%d",&a[0],&a[1],&a[2]);
if(a[0]==0&&a[1]==0&&a[2]==0)
return 0;
for(i=0;i<3;i++)
{
while(!have[i].empty())
have[i].pop();
}
ans=0;
u[0]=0,u[1]=0,u[2]=0;
while(1)
{
do{
scanf("%c",&c);
}while(! (c=='#'||(c<='9'&&c>='0')) );
if(c=='#')break;
scanf("%d:%d %d",&t1,&t2,&nd.dinners);
nd.time=((c-'0')*10+t1)*60+t2;
i=(nd.dinners-1)/2;
// if(i>=3||i<0)continue;
while(!have[i].empty())
{
nd1=have[i].front();
if(nd1.time>nd.time)
break;
ans+=nd1.dinners;
have[i].pop();
u[i]--;
}
if(u[i]==a[i]&&!have[i].empty())
{
nd1=have[i].front();
if(nd1.time<=nd.time+30)
{
ans+=nd1.dinners;
nd.time=nd1.time;
have[i].pop();
u[i]--;
}
}
if(u[i]<a[i])
{
u[i]++;
nd.time+=30;
if(nd.time<=23*60)
have[i].push(nd);
}
}
for(i=0;i<3;i++)
while(!have[i].empty())
{
nd1=have[i].front();
ans+=nd1.dinners;
have[i].pop();
u[i]--;
}
return 1;
}
int main()
{
while(init())
{
printf("%d\n",ans);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -