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的值最优,每 ...
随机推荐
- Java 定时任务 & 任务调度
任务调度是指基于 给定时间点,给定时间间隔 或者 给定执行次数 自动执行任务. 方式1:通过 Thread 来实现 例如如下的代码,可以每隔 1000 毫秒做一次打印操作. public class ...
- 创建maven web项目无法创建sec目录
创建maven web项目无法创建sec目录 解决方法:-DarchetypeCatalog=internal
- web前端入坑第二篇:web前端到底怎么学?干货资料! 【转】
http://blog.csdn.net/xllily_11/article/details/52145172 版权声明:本文为博主[小北]原创文章,如要转载请评论回复.个人前端公众号:前端你别闹,J ...
- Gpu driven rendering pipelines & bindless texture
http://advances.realtimerendering.com/s2015/aaltonenhaar_siggraph2015_combined_final_footer_220dpi.p ...
- 关于json对象的删除
摘自:http://xosadan.iteye.com/blog/1100383 关于json对象的删除 一个json对象在后台产生了,但是有些数据可能无效或者不合法,所以需要在前台作些例外处理,比如 ...
- css border-sizing 用法与理解
浏览器支持 IE Firefox Chrome Safari Opera 支持 支持 支持 支持 支持 Internet Explorer.Opera 以及 Chrome 支持 box-si ...
- [Angular] AfterContentChecked && AfterViewChecked
AfterContentChecked & AfterViewChecked are called after 'OnChanges' lifecycle. And each time 'ng ...
- automake连载--Linux下使用automake入门
http://blog.csdn.net/shanzhizi/article/details/30246587 近来重要要总结一下automake的用法了,连载几篇网上已有的文章,以供参考. 作为Li ...
- 虚拟机VMware12.0安装centos 6.5+VMware中虚拟机网络模式区分
之前的步骤一路next,有设置内存大小的根据机器的配置设置一下即可. 需要注意的地方, 下面是对于简化版进行设置的步骤 虚拟机网络模式 1.桥接模式 在桥接模式下,VMware虚拟机里的系统就像是 局 ...
- JS中如何alert对象
alert(JSON.stringify(res)); alert(JSON.stringify(res)); alert(JSON.stringify(res)); 文章来源:刘俊涛的博客 地址:h ...