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;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

posted @ 2015-07-10 18:16  phlsheji  阅读(306)  评论(0编辑  收藏  举报