TIANKENG’s rice shop

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<m;i++)
27         {
28             scanf("%d:%d %d %d",&hh,&mm,&a,&b);
29             hh=hh*60+mm;
30             if(type[a]>=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 }

TIANKENG’s rice shop

时间: 2024-10-10 06:08:21

TIANKENG’s rice shop的相关文章

HDU TIANKENG’s rice shop(模拟)

HDU 4884 TIANKENG's rice shop 题目链接 题意:模拟题.转一篇题意 思路:就模拟就可以.注意每次炒完之后就能够接单 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 1005; int T, n, t, k, m; struct Person { int t, p, num, ans; } p[N];

【HDOJ】4884 TIANKENG&#39;s rice shop

简单模拟,注意并不是完全按照FIFO的顺序.比如第i个人的id为k,那么就算第i+1人的id不为k,也会检查他后续的排队人是否有id为k的. 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 5 #define MAXN 1005 6 7 typedef struct { 8 int tt; 9 int id; 10 int num; 11 int ans; 12 } need_st; 13

[ACM] HDU 4884 TIANKENG’s rice shop (模拟)

TIANKENG's rice shop 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

hdu4884 TIANKENG’s rice shop【模拟】

TIANKENG's rice shop Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 345    Accepted Submission(s): 71 Problem Description TIANKENG managers a pan fried rice shop. There are n kinds of fried ri

hdu 4884 TIANKENG’s rice shop(模拟)

# include <cstdio> # include <algorithm> # include <cstring> # include <cstdlib> using namespace std; int max(int a,int b) { return a>b?a:b; } int main() { int T,n,t,k,m,i,hh,min,id,num,x; int last[1010];//最后一次開始炒饭的时间 int cot[10

hdu4884TIANKENG’s rice shop(模拟)

题目:hdu4884TIANKENG's rice shop(模拟) 题目大意:一家餐厅买炒饭,给你客人来的时间和要买的炒饭的数量种类,并且也知道炒一次炒饭最多的分数和时间,问这些客人最早的离开时间.注意:每次炒饭的那段时间是不接单的. 解题思路:模拟.题意好坑,还有根本不会有23:59 , 00:00这样的输入数据,只是输出可能会跨一天.然后就是模拟了.好恶心的题目.详细的看注释把. 代码: #include <cstdio> #include <cstring> #includ

HDOJ 4884 &amp; BestCoder#2 1002

TIANKENG’s rice shop Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 212    Accepted Submission(s): 9 Problem Description TIANKENG managers a pan fried rice shop. There are n kinds of fried rice

计算理论中的莱斯定理(Rice&#39;s Theorem)——证明与应用

我们给出一个在探讨不可判定性时非常有用的结论--莱斯定理(Rice's Theorem).首先,我们来看前面讨论过的几个不可判定的例子: 这些都是由图灵机识别之语言的性质.而莱斯定理告诉我们,任何由图灵机识别之语言的非平凡性质(nontrivial property)都是不可判定的. 最后通过几个例子来探讨一下莱斯定理的应用.来看看下面这个语言能否使用莱斯定理来确定其可判定性. {<M> | M是一个TM,且L(M)可由一些拥有偶数个状态的图灵机识别} 首先来确定这是否是一个语言属性,显然是的

hdu 4122 Alice&#39;s mooncake shop

题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4122 题意大意是Alice开着一家月饼店,可以接到n做月饼的订单,而Alice只有在从2000年一月一日0点为第一个小时开始的前m个小时内做月饼,而且只能在整点 的时候做月饼,并且做月饼不花费时间,也就是一瞬间就可以做超级多的月饼,而每个月饼有t个小时的保质期,每个月饼保存每小时需要花费s元,而在可以 做月饼的m小时内,不同小时做月饼花费的钱也不同,每个订单都有交付订单嗯达时间,某年某月某日某时交付该