博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TIANKENG’s rice shop
阅读量:6610 次
发布时间:2019-06-24

本文共 2728 字,大约阅读时间需要 9 分钟。

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
1 #include"iostream" 2 #include"cstdio" 3 #include"cstring" 4 #include"algorithm" 5 using namespace std; 6 const int ms=1010; 7 const int lim=24*60; 8 int T,n,k,t,m; 9 int type[ms];10 int last[ms];11 void print(int time)12 {13     if(time>=lim)14         time%=lim;15     printf("%02d:%02d\n",time/60,time%60);16 }17 int main()18 {19     cin>>T;20     while(T--)21     {22         cin>>n>>t>>k>>m;23         memset(type,0,sizeof(type));24         int hh,mm,a,b;25         int cur=0;26         for(int i=0;i
=b&&last[a]>=hh)31 {32 type[a]-=b;33 print(last[a]+t);34 continue;35 }36 if(type[a]&&last[a]>=hh)37 {38 b-=type[a];39 }40 int x=(b-1)/k+1;41 cur=max(cur,hh)+t*x;42 print(cur);43 type[a]=x*k-b;44 last[a]=cur-t;45 }46 if(T)47 puts("");48 }49 return 0;50 }

 

转载于:https://www.cnblogs.com/767355675hutaishi/p/3889944.html

你可能感兴趣的文章
TensorFlow-谷歌深度学习库 手把手教你如何使用谷歌深度学习云平台
查看>>
程序局部性原理的一些思考
查看>>
JavaScript作用域和作用域链
查看>>
[]ARC098
查看>>
JAVA第四次实验
查看>>
IAR 配置
查看>>
for / forEach / for in /for of 的区别及优势
查看>>
【论文学习】A Study of Equivalent and Stubborn Mutation Operators using Human Analysis of Equivalence...
查看>>
如何将自己写的verilog模块封装成IP核
查看>>
python3 urllib.request 网络请求操作
查看>>
Entity Framework with MySQL 学习笔记一(乐观并发)
查看>>
关于js中的date处理
查看>>
德识才学-判断人的四个方面
查看>>
5.10 数据库视图
查看>>
牛客面经
查看>>
Zookeeper使用--命令行
查看>>
Java之CountDownLatch使用
查看>>
转 Spring Security 简介
查看>>
CSS Hack解决浏览器IE部分属性兼容性问题
查看>>
第11次作业
查看>>