首页 > 代码库 > hdu 4884 TIANKENG’s rice shop(模拟)

hdu 4884 TIANKENG’s rice shop(模拟)

# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cstdlib>
using namespace std;
int max(int a,int b)
{
	return a>b?a:b;
}
int main()
{
	int T,n,t,k,m,i,hh,min,id,num,x;
	int last[1010];//最后一次开始炒饭的时间
	int cot[1010];//剩下的炒饭
	scanf("%d",&T);
    while(T--)
	{
		scanf("%d%d%d%d",&n,&t,&k,&m);
		memset(cot,0,sizeof(cot));
		int cur=0;
		while(m--)
		{
			scanf("%d:%d%d%d",&hh,&min,&id,&num);
			hh=hh*60+min;
			if(cot[id]>=num&&last[id]>=hh)
			{
				cot[id]-=num;
				printf("%02d:%02d\n",((last[id]+t)/60)%24,(last[id]+t)%60);
				continue;
			}
			if(cot[id]&&last[id]>=hh)
			{
				num-=cot[id];
			}
			if(num%k)//还需要抄几次
				x=num/k+1;
			else
				x=num/k;
			cur=max(cur,hh)+t*x;
			printf("%02d:%02d\n",(cur/60)%24,cur%60);
			cot[id]=x*k-num;
			last[id]=cur-t;
		}
		if(T)
			puts("");
	}
	return 0;
}