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教程之Button篇(1)

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811298 #Tkinter教程之Button篇(1)#Button功能触发事件'''1.一个 ...

  2. 王家林的81门一站式云计算分布式大数据&移动互联网解决方案课程第14门课程:Android软硬整合设计与框架揭秘: HAL&Framework &Native Service &App&HTML5架构设计与实战开发

    掌握Android从底层开发到框架整合技术到上层App开发及HTML5的全部技术: 一次彻底的Android架构.思想和实战技术的洗礼: 彻底掌握Andorid HAL.Android Runtime ...

  3. 【转】一步步教你读懂NET中IL(图文详解)

    本文章以一个实际的例子,让你了解堆叠式 VM 的运作原理,并对 .NET IL(Intermediate Language)有最基本的領略,需要的朋友可以参考下  .NET CLR 和 Java VM ...

  4. Cocos2dx-截屏并设置图片尺寸

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=522 前几天添加微信图片分享的时 ...

  5. JSF 2 textarea example

    In JSF, you can use the <h:inputTextarea /> tag to render a HTML textarea field. For example, ...

  6. Google中rel="canonical"的相关解释和用法

    转载原地址 http://blog.sina.com.cn/s/blog_673b01740100jxlz.html 近听到很多SEO 对在页面的规范版本用规范 URL 标签( canonical U ...

  7. uva 1356 Bridge ( 辛普森积分 )

    uva 1356 Bridge ( 辛普森积分 ) 不要问我辛普森怎么来的,其实我也不知道... #include<stdio.h> #include<math.h> #inc ...

  8. Codeforces Round #201 (Div. 2) - C. Alice and Bob

    题目链接:http://codeforces.com/contest/347/problem/C 题意是给你一个数n,然后n个数,这些数互不相同.每次可以取两个数x和y,然后可以得到|x - y|这个 ...

  9. Spring Data JPA教程, 第六部分: Sorting(未翻译)

    The fifth part of my Spring Data JPA tutorialdescribed how you can create advanced queries with Spri ...

  10. time_t转换为DateTime

    最近解析文华财经的日线数据. 取得的第一个字段是日期,为time_t格式(long)的. 因为是用C#来写解析程序,所以要转换为DateTime的. time_t是世界时间,要转换为本地时间,所以要加 ...