TIANKENG’s rice shop
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)
time referring to the departure time of the customer. There is a blank line
between two test cases.
#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的更多相关文章
- HDU 4884 TIANKENG’s rice shop (模拟)
TIANKENG's rice shop 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/J Description TIANKE ...
- HDU TIANKENG’s rice shop(模拟)
HDU 4884 TIANKENG's rice shop 题目链接 题意:模拟题.转一篇题意 思路:就模拟就可以.注意每次炒完之后就能够接单 代码: #include <cstdio> ...
- 【HDOJ】4884 TIANKENG's rice shop
简单模拟,注意并不是完全按照FIFO的顺序.比如第i个人的id为k,那么就算第i+1人的id不为k,也会检查他后续的排队人是否有id为k的. #include <cstdio> #incl ...
- hdu 4884 TIANKENG’s rice shop(模拟)
# include <cstdio> # include <algorithm> # include <cstring> # include <cstdlib ...
- HDOJ 4884 & BestCoder#2 1002
TIANKENG’s rice shop Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 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 ...
- Codeforces632E Thief in a Shop(NTT + 快速幂)
题目 Source http://codeforces.com/contest/632/problem/E Description A thief made his way to a shop. As ...
- poj1157LITTLE SHOP OF FLOWERS
Description You want to arrange the window of your flower shop in a most pleasant way. You have F bu ...
- Magicodes.Shop——版本历史
Magicodes.Shop为湖南心莱信息科技有限公司(xin-lai.com)Magicodes系列产品之一. 产品中引用的Magicodes系列Nuget包的开源库地址为:https://gith ...
随机推荐
- KMP(字符串匹配)
1.KMP是一种用来进行字符串匹配的算法,首先我们来看一下普通的匹配算法: 现在我们要在字符串ababcabcacbab中找abcac是不是存在,那么传统的查找方法就是一个个的匹配了,如图: 经过六趟 ...
- Java每日一则-001
Java中类名与文件名的关系 1.Java保存的文件名必须与类名一致: 2.如果文件中只有一个类,文件名必须与类名一致: 3.一个Java文件中只能有一个public类: 4.如果文件中不止一个类,文 ...
- nodejs+express +jade模板引擎 新建项目
先 安装 nodejsiDEAAM 2015/7/16 22:47:25然后安装 npm install expressiDEAAM 2015/7/16 22:47:35然后安装 npm instal ...
- the application could not be verified
在iphone上安装app时,提示the application could not be verified 解决方式: 将iphone已有的这个app卸载,然后安装就可以了.
- 你想成为优秀的Java程序员吗?
Java是全世界最受欢迎的3大编程语言之一,它可以开发出许多实用的WEB应用程序和桌面应用程序,更重要的一点,Java是跨平台的语言——编写一次,可以再任何地方运行.另外,Java也很容易入门,如果你 ...
- 第二百九十、一、二天 how can I 坚持
上周日,腊八,好冷,去菏泽了.坐火车,没座.好冷,下午菏泽学院,大体看了看,很是怀念,有点遗憾,在网吧玩的时间太长了,留不住. 周一,长太婚礼,竟然没有只是吃了个饭,有点小失望,下午坐车回京,两点坐的 ...
- 教程-Close、Halt、terminate、ExitProcess的区别
Close:1.只关闭本窗体2.当Close是一个主窗体时,程序会退出.3.Close会发生FormClose事件,FormCloseQuery事件4.主窗体close以后程序就Application ...
- POJ3278http://poj.org/problem?id=3278
http://poj.org/problem?id=3278 题目大意: m,n两个数m可+1, -1, *2变成n,需要经过几步 #include<stdio.h> #include&l ...
- [iOS UI进阶 - 4.0] 涂鸦app Demo
A.需求 1.超简易画图,只有一种画笔 2.清屏功能 3.回退功能 4.保存功能 5.使用了cocos2D code source: https://github.com/hellovoidwor ...
- UVaLive 6862 Triples (数学+分类讨论)
题意:给定一个n和m,问你x^j + y^j = z^j 的数量有多少个,其中0 <= x <= y <= z <= m, j = 2, 3, 4, ... n. 析:是一个数 ...