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的值最优,每 ...
随机推荐
- iOS 在某一个ViewController跳转到TabViewController中的某一个ViewController
要做到这个分为两步 第一步, 导入app #import "AppDelegate.h" 第二步, 监听方法中先写加入以下代码: [self dismissViewControll ...
- jquery load 方法回显数据
使用jQuery对象.load()方法 load() 方法的作用是可以通过 AJAX 请求从服务器加载数据,并把返回的数据直接放置到指定的元素中. 该方法使用起来非常简单,大大简化了ajax开发 语法 ...
- mac设置多个屏幕显示的问题
点击 设置 -> 显示器 -> 排列,然后拉着菜单在两个显示器之间切换.
- idea中git从码云克隆项目到本地
1.首先需要在操作系统上安装Git分布式管理系统 此处自行百度............. 2.在Intellij IDEA中配置Git 打开Settings(File-->Settings) - ...
- 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-如何在初始化的时候写入参数
最常见的是定义一个全局变量,然后跟对应的变量绑定,比如我定义了一个SINT型的变量ControlWord 数值是8,定义好之后编译一下,可以发现PLC程序中或多出来这个变量(MAIN.ControlW ...
- Mach-O文件格式和程序从载入到运行过程
> 之前深入了解过.过去了一年多的时间.如今花些时间好好总结下,毕竟好记性不如烂笔头. 其次另一个目的,对于mach-o文件结构.关于动态载入信息那个数据区中,命令含义没有深刻掰扯清除,希望有同 ...
- P2P网络借贷系统-核心功能-用户投标-业务解说
用户投标是P2P网络借贷系统的核心功能.相对照较复杂,为了更好地梳理业务和技术实现思路,特地具体总结分析下. 输入:用户id-uid.标的id-lid.投标金额-amount 1.依据lid,获得贷款 ...
- ajax同步和异步
// 方案2: 回调函数 // function getFile( callback ){ // // 1: 创建ajax对象 XMLHttpRequest // var xhr = new XMLH ...
- Openerp约束句型
内容摘自:http://blog.csdn.net/sz_bdqn/article/details/8785483 _constraints _constraints可以灵活定义OpenERP对象的约 ...
- POJ 1163&& 3176 The Triangle(DP)
The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41169 Accepted: 24882 De ...