HDU 4884 TIANKENG’s rice shop (模拟)

网友投稿 211 2022-08-30

HDU 4884 TIANKENG’s rice shop (模拟)

Problem Description

TIANKENG managers a pan fried rice shop. There are n kinds of fried rice numbered 1-n. TIANKENG will spend t time for once frying. Because the pan is so small, TIANKENG can fry k bowls of fried rice with same kind at most. Assuming that there are m customers coming to the shop, and we know the arriving time of each customer and the brand and number of the fried rice they need. Could you tell TIANKENG the departure time of every customer respectively? Pay attention that TIANKNEG will serve the customer who comes earlier and he will fry the rice as much as possible. Meanwhile, customers are in queue depending on their arriving time(the earlier they arrive, the more front they stand).

Input

The first line contains a positive integer T(T<=100), referring to T test cases. For each test case, the first line has 4 positive integer n(1<=n<=1000), t(1<=t<=10), k(1<=k<=5), m(1<=m<=1000), then following m lines , each line has a time(the time format is hh:mm, 0<=hh<=23, 0<=mm<=59) and two positive integer id(1<=id<=n), num(1<=num<=10), which means the brand number of the fried rice and the number of the fried rice the customer needs. Pay attention that two or more customers will not come to the shop at the same time, the arriving time of the customer will be ordered by the time(from early time to late time)

Output

For each test case print m lines, each line contains a time referring to the departure time of the customer. There is a blank line between two test cases.

Sample Input

32 1 4 208:00 1 509:00 2 12 5 4 308:00 1 408:01 2 208:02 2 22 5 4 208:00 1 108:04 1 1

Sample Output

08:0209:0108:0508:1008:1008:0508:10

题意

有n种炒饭,每次炒的时间是t分钟,每次最多炒k份,然后按照进店的顺序给出m个顾客的信息,进店时间,炒饭编号以及份数,输出每个顾客离开的时间。

思路

顾客是先来先服务,并且每次会尽可能多的去炒。

我们可以存储上次炒饭可以容纳的份数以及开炒时间,如果时间晚于当前顾客的到来时间,则把当前顾客的份添加进去一起做,如果有剩余的份,则单独计算离开时间,并维护存储这两个值。

AC 代码

#include#include#include#include#include#includeusing namespace std;#include#includeint sk[1100],lt[1100];int main(){ int T; scanf("%d",&T); for(int ti=1; ti<=T; ti++) { int n,t,k,m,time=0; scanf("%d%d%d%d",&n,&t,&k,&m); memset(sk,0,sizeof(sk)); //上次炒饭还可以容纳的份数 memset(lt,0,sizeof(lt)); //上次炒饭开始的时间 for(int i=0; i=hour) //如果顾客早于开始炒饭的时间 { if(sk[id]>=num) //当前顾客的份可以加到前面一起炒 { sk[id]-=num;// cout<

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:关于汽车线上营销这件事,字节跳动有话说!(字节跳动汽车行业销售经理)
下一篇:POJ 2195 Going Home (最小费用最大流)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~