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. 瞬间从IT屌丝变大神——HTML规范

    HTML规范包含以下内容: DTD统一用<!DOCTYPE HTML PUBLIC "_//W3C//DTD XHTML 1.0 Transitional//EN"" ...

  2. 在已创建的DataTable对象中添加在首列一列

    问题描述: 从数据库读取出来的表数据赋给到了DataTable上,将DataTable中数据显示到DataGridView中时希望在DataGridView的第一列显示一列. 解决方法: DataTa ...

  3. Merge Cells for DataGrid 合并单元格

    只适合不分页的固定行列的表格 <script type="text/javascript"> function onLoadSuccess(data){ var mer ...

  4. append some buttons to the standard datagrid pager bar

    <script type="text/javascript">  $(function(){   var pager = $('#dg').datagrid('getP ...

  5. 第三百零七天 how can I 坚持

    快放假了,上班也没啥事,感觉也挺累的.明天基本都走了,收拾收拾,准备明天出发.电脑就不带了. 和她聊的还可以,小样,还想当老师,别离开济南就行,我的未来在哪里啊. 晚上炒了白菜,下了乌冬面,明天上午晚 ...

  6. 【转】Maven实战(四)---多模块项目---JBOSS部署问题

    原文出自于:http://blog.csdn.net/liutengteng130/article/details/41622681      感谢! 这几天在搭框架中仅仅是JBOSS就遇到了很多问题 ...

  7. CoffeeScript学习(3)—— 函数

    CoffeeScript函数 如果大家有看我之前关于ES6的箭头函数的话,这一篇也不会很难理解.我们这一次可以说一下,关于两者的一些细微差别. 基本 在CoffeeScript中,任何函数都是用箭头函 ...

  8. Spring4整合Hibernate4详细示例

    1. Spring整合Hibernate,主要是解决什么问题? a.让Spring提供的IOC容器来管理Hibernate的SessionFactory b.让Hibernate使用Spring提供的 ...

  9. python crawler0723.py

    #!/usr/env  python #-*- coding: utf-8  -*- import urllib import urllib2 import random import request ...

  10. ckeditor内容保存后显示问题

    ckeditor保存到数据库中的数据是html格式,如果要在前台进行显示,需要采用${news.content },这样数据才能进行正常的显示,否则如果采用<s:property value=& ...