# 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];//the last time the fried rice was opened int cot[1010];//the remaining fried rice 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)//also need to copy several times X=num/k+1;elsex=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;}
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
Hdu 4884 Tiankeng ' s rice Shop (analogue)