HDOJ 4884 & 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
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)
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
09:01
08:05
08:10
08:10
08:05
08:10
08:06 1 8 做他的第二轮的时候,顺便把三号的也可以做了(可以这样的)他的第一轮结束时间: 08:11
08:07 2 11
08:08 1 1
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int N = ;
const int lim = *;
int T, n, t, k, m;
int type[N];//表示上一个顾客走后,第N种饭的空缺;
int last[N];//开始做上一个顾客,最后一轮饭的时间
void print(int time)
{
if(time>=lim) time%=lim;
printf("%02d:%02d\n", time/, time%);
}
int main(){
scanf("%d", &T);
while(T--){
scanf("%d %d %d %d", &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;
/*如果a钟饭还能做的份数,大于b,
并且这一轮的开始时间大于他来的时间
例如:2 5 5 3
08:06 1 8 做他的第二轮的时候,顺便把三号的也做了(可以这样)
08:07 2 11
08:08 1 1
*/
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 ;
}
HDOJ 4884 & BestCoder#2 1002的更多相关文章
- Bestcoder#5 1002
Bestcoder#5 1002 Poor MitsuiTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
- [HDOJ 5212] [BestCoder Round#39] Code 【0.0】
题目链接:HDOJ - 5212 题目分析 首先的思路是,考虑每个数对最终答案的贡献. 那么我们就要求出:对于每个数,以它为 gcd 的数对有多少对. 显然,对于一个数 x ,以它为 gcd 的两个数 ...
- bestcoder#23 1002 Sequence II 树状数组+DP
Sequence II Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- 暴力+降复杂度 BestCoder Round #39 1002 Mutiple
题目传送门 /* 设一个b[]来保存每一个a[]的质因数的id,从后往前每一次更新质因数的id, 若没有,默认加0,nlogn复杂度: 我用暴力竟然水过去了:) */ #include <cst ...
- DFS ZOJ 1002/HDOJ 1045 Fire Net
题目传送门 /* 题意:在一个矩阵里放炮台,满足行列最多只有一个炮台,除非有墙(X)相隔,问最多能放多少个炮台 搜索(DFS):数据小,4 * 4可以用DFS,从(0,0)开始出发,往(n-1,n-1 ...
- 矩阵快速幂---BestCoder Round#8 1002
当要求递推数列的第n项且n很大时,怎么快速求得第n项呢?可以用矩阵快速幂来加速计算.我们可以用矩阵来表示数列递推公式比如fibonacci数列 可以表示为 [f(n) f(n-1)] = [f(n ...
- BestCoder #47 1001&&1002
[比赛链接]cid=608">clikc here~~ ps:真是wuyu~~做了两小时.A出两道题,最后由于没加longlong所有被别人hack掉!,最后竟然不知道hack别人不成 ...
- BestCoder Round #92 1002 Count the Sheep —— 枚举+技巧
题目链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=748&pid=1002 题解: 做题的时候只是想到 ...
- 贪心/二分查找 BestCoder Round #43 1002 pog loves szh II
题目传送门 /* 贪心/二分查找:首先对ai%=p,然后sort,这样的话就有序能使用二分查找.贪心的思想是每次找到一个aj使得和为p-1(如果有的话) 当然有可能两个数和超过p,那么an的值最优,每 ...
随机推荐
- jQuery中resetForm与clearForm的区别?
reset是重置成最初状态,最初状态是可能有默认值的clear是清空form控件的值
- attribute用法
attribute 用法 摘要: 在学习linux内核代码及一些开源软件的源码(如:DirectFB),经常可以看到有关__attribute__的相关使用.本文结合自己的学习经历,较为详细的介绍了_ ...
- linux自定义开机启动服务和chkconfig使用方法
linux自定义开机启动服务和chkconfig使用方法 1. 服务概述在linux操作系统下,经常需要创建一些服务,这些服务被做成shell脚本,这些服务需要在系统启动的时候自动启动,关闭的时候自动 ...
- Linq之旅:Linq入门详解(Linq to Objects)【转】
http://www.cnblogs.com/heyuquan/p/Linq-to-Objects.html Linq之旅:Linq入门详解(Linq to Objects) 示例代码下载:Linq之 ...
- 摄像头模组 AWB(Auto White Balance)
本文转载yapingmcu的<图像算法---白平衡AWB(讲的很好)>.原文http://blog.csdn.net/yapingmcu/article/details/50637797 ...
- Eight_pku_1077(广搜).java
Eight Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21718 Accepted: 9611 Special ...
- 【实践】js封装 jq siblings 方法
思路: 1.获取调用元素的父元素下的所有子元素(即它的所有同辈元素和调用元素本身) 2.遍历调用元素父元素下的所有子元素 除调用元素外的所有元素保存在一个数组里面 代码如下: <!DOCTYPE ...
- MySQL分库备份与分表备份
MySQL分库备份与分表备份 1.分库备份 要求:将mysql数据库中的用户数据库备份,备份的数据库文件以时间命名 脚本内容如下: [root@db01 scripts]# vim backup_da ...
- git 批量删除文件夹和文件
git 批量删除文件夹和文件 硬盘删除文件后,执行$ git status 会提示你仍然需要$ git rm <文件> 此时如果是要删除大批量文件,这么一个一个命令下去不得累死人啊 ...
- 请远离include_once和require_once[转]
来自:http://www.poluoluo.com/jzxy/201306/216921.html 尽量使用include, 而不是include_once, 理由是 include_once需要查 ...