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
3
2 1 4 2
08:00 1 5
09:00 2 1
2 5 4 3
08:00 1 4
08:01 2 2
08:02 2 2
2 5 4 2
08:00 1 1
08:04 1 1
 
Sample Output
08:02
09:01
 
08:05
08:10
08:10
 
 
08:05
08:10
 #include"iostream"
#include"cstdio"
#include"cstring"
#include"algorithm"
using namespace std;
const int ms=;
const int lim=*;
int T,n,k,t,m;
int type[ms];
int last[ms];
void print(int time)
{
if(time>=lim)
time%=lim;
printf("%02d:%02d\n",time/,time%);
}
int main()
{
cin>>T;
while(T--)
{
cin>>n>>t>>k>>m;
memset(type,,sizeof(type));
int hh,mm,a,b;
int cur=;
for(int i=;i<m;i++)
{
scanf("%d:%d %d %d",&hh,&mm,&a,&b);
hh=hh*+mm;
if(type[a]>=b&&last[a]>=hh)
{
type[a]-=b;
print(last[a]+t);
continue;
}
if(type[a]&&last[a]>=hh)
{
b-=type[a];
}
int x=(b-)/k+;
cur=max(cur,hh)+t*x;
print(cur);
type[a]=x*k-b;
last[a]=cur-t;
}
if(T)
puts("");
}
return ;
}

TIANKENG’s rice shop的更多相关文章

  1. HDU 4884 TIANKENG’s rice shop (模拟)

    TIANKENG's rice shop 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/J Description TIANKE ...

  2. HDU TIANKENG’s rice shop(模拟)

    HDU 4884 TIANKENG's rice shop 题目链接 题意:模拟题.转一篇题意 思路:就模拟就可以.注意每次炒完之后就能够接单 代码: #include <cstdio> ...

  3. 【HDOJ】4884 TIANKENG's rice shop

    简单模拟,注意并不是完全按照FIFO的顺序.比如第i个人的id为k,那么就算第i+1人的id不为k,也会检查他后续的排队人是否有id为k的. #include <cstdio> #incl ...

  4. hdu 4884 TIANKENG’s rice shop(模拟)

    # include <cstdio> # include <algorithm> # include <cstring> # include <cstdlib ...

  5. HDOJ 4884 & BestCoder#2 1002

    TIANKENG’s rice shop Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  6. codeforces 632+ E. Thief in a Shop

    E. Thief in a Shop time limit per test 5 seconds memory limit per test 512 megabytes input standard ...

  7. Codeforces632E Thief in a Shop(NTT + 快速幂)

    题目 Source http://codeforces.com/contest/632/problem/E Description A thief made his way to a shop. As ...

  8. poj1157LITTLE SHOP OF FLOWERS

    Description You want to arrange the window of your flower shop in a most pleasant way. You have F bu ...

  9. Magicodes.Shop——版本历史

    Magicodes.Shop为湖南心莱信息科技有限公司(xin-lai.com)Magicodes系列产品之一. 产品中引用的Magicodes系列Nuget包的开源库地址为:https://gith ...

随机推荐

  1. Tkinter教程之Text(2)篇

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811347 '''Tkinter教程之Text(2)篇''''''6.使用tag来指定文本的属 ...

  2. 机器学习框架Scikit Learn的学习

    一   安装 安装pip 代码如下:# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=83 ...

  3. Codeforces 375

    A 7的所有的余数都可以用1,6,8,9排列得到,然后搞一下就可以了. B 可以用类似于单调队列的东西搞.具体看代码: /* * Problem: B. Maximum Submatrix 2 * A ...

  4. 1分钟内检查Linux服务器性能的10条命令

    如果你的Linux服务器突然负载暴增,告警短信快发爆你的手机,如何在最短时间内找出Linux性能问题所在?Netflix性能工程团队的Brendan Gregg写下了这篇博文,来看他们是怎样通过十条命 ...

  5. JDBC学习笔记(9)——DBUtils的使用

    使用DBUtils提供的功能需要使用commons-dbutils-1.6.jar这个JAR包,在Apache官网可以下载到 使用DBUtils进行更新操 测试QueryRunner类的update方 ...

  6. HDU 5828 Rikka with Sequence (线段树)

    Rikka with Sequence 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5828 Description As we know, Rik ...

  7. HTTP常见错误 400/401/403/404/500及更多

    HTTP 错误 400 400 请求出错 由于语法格式有误,服务器无法理解此请求.不作修改,客户程序就无法重复此请求. HTTP 错误 401 401.1 未授权:登录失败 此错误表明传输给服务器的证 ...

  8. JVM 关闭前执行命令的钩子

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { System.out.prin ...

  9. Protobuf一键生成代码bat文件

    最近在摆弄Unity的Socket,需要用到Protobuf,一般都会有多个协议文件,所以研究了下bat的批处理,下面给出批处理文件代码: @echo off ::协议文件路径, 最后不要跟“\”符号 ...

  10. Velocity中#set指令

    引用可以让模板设计者生成动态内容,而指令允许设计者真正的负责页面的展现和内容. 指令是以#开头,后面紧跟一个关键字,比如if,else,foreach等.而这个关键字,是可以被放在{}中间的.这是规范 ...