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 ...
随机推荐
- 【Spark学习】Apache Spark监控与测量
Spark版本:1.1.1 本文系从官方文档翻译而来,转载请尊重译者的工作,注明以下链接: http://www.cnblogs.com/zhangningbo/p/4137952.html
- Deep Learning Practice【开篇】
Chapter 0 初入深度学习实战 最近一直在学习深度学习相关的知识,看文献,看博客,看书,与别人讨论,等等,但是总觉得这样的学习只是停留在表面,无法去深入的学习到深度学习的内幕.于是,决定开始深度 ...
- Form(表单)
使用$.fn.form.defaults重写默认值对象 form提供了各种方法来操作执行表单字段,比如:ajax提交, load, clear等等.当提交表单的时候可以调用validate方法检查表单 ...
- ocp 1Z0-051 71-105题解析
71. Which arithmeticoperations can be performed on a column by using a SQL function that is builtint ...
- HDU 5623 KK's Number (博弈DP)
KK's Number 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/K Description Our lovely KK h ...
- POj3268 Silver Cow Party
http://poj.org/problem?id=3268 题目大意:求到x距离与从x返回和的最大值 从x点到各个点最短路好求,直接用Dijkstar,但从各个点到x点却不好求,只要把路向翻转过来也 ...
- HTML5实现动画三种方式
编者注:作者以一个运动的小车为例子,讲述了三种实现HTML5动画的方式,思路清晰,动画不仅仅是canvas,还有css3和javascript.通过合理的选择,来实现最优的实现. PS:由于显卡.录制 ...
- 前端的一些常用DOM和事件归纳
1.document.getElementById(id); document.getElementByTagName(tagName); document.getElementsByNa ...
- Codeforces Round #337 (Div. 2) D. Vika and Segments (线段树+扫描线+离散化)
题目链接:http://codeforces.com/contest/610/problem/D 就是给你宽度为1的n个线段,然你求总共有多少单位的长度. 相当于用线段树求面积并,只不过宽为1,注意y ...
- [原]使用node-mapnik和openstreetmap数据初步搭建瓦片服务
最近依然还是有点小忙,只能挤点时间来学习点,先解决有没有的问题,再解决好不好的问题:) 本文将承接上文<使用node-mapnik生成openstreetmap-carto风格的瓦片>的内 ...