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的值最优,每 ...
随机推荐
- exVim安装
安装 安装必备 Vim 7.3 or higher. Vundle or Pathogen 下载/更新exVim 注意事项 安装exVim将不会覆盖你已经存在的Vim环境,这个仓库所包含的文件,变化, ...
- Groovy(java)+Spock+IDEA+maven+Jenkins+SVN+maven-surefire-plugin+maven-surefire-report-plugin/maven-antrun-extended-plugin集成接口测试框架
文章为原创,未经本人授权禁止转载. 一.spock框架环境搭建. 二.基于spock框架的脚本开发. 三.基于spock框架的用例执行并生成HTML报告. 四.集成jenkins生成HTML报告. 五 ...
- 我的自动化测试历程(Selenium+TestNG+Java+ReportNG+Jenkins)
原地址:http://blog.csdn.net/shilinjie_8952/article/details/53380373?locationNum=11&fps=1 测试环境:Java+ ...
- Android的四大天王
Android 四大天王 1.Activity 2.Intent Receiver 3.Service 4.Content Provider 但是,并不是每一个Android应用程序都需要这四种 ...
- 极光推送sdk使用
创建应用 进入极光控制台后,点击“创建应用”按钮,进入创建应用的界面. 填上你的应用程序的名称以及应用包名这二项就可以了, 最后点击最下方的 “创建我的应用”按钮,创建应用完毕. 创建应用 填 ...
- 关于app更新安装闪退和EditText长按出现的水滴颜色设置问题
关于app应用内更新安装后闪退的问题,解决办法如下: private void updateApp(File body) { Intent intent = new Intent(Intent.ACT ...
- Unity3D性能优化小tips——把this.transform缓存缓存起来
Unity3D开发时中有一个小tips,这在官方的文档里其实有提及的,但不那么显眼,这里小说一下: 在MonoBehaviour进行编程时,我们经常会用this.transform, this.gam ...
- C、C++中如何成功嵌入python
修改lib文件名称,拷贝修改C:\Python27\libs目录下原来的python27.lib为python27_d.lib 包含头文件在C:\Python27\include目录下 包含lib文件 ...
- SVN 常见命令
一.什么是SVN SVN是Subversion的简称,是一个开放源代码的版本控制系统,相较于RCS.CVS,它采用了分支管理系统,它的设计目标就是取代CVS. 二.SVN的下载安装 下载地址:http ...
- es6 对象简化写法-函数
表达式还可以用于定义方法名. let obj = { ['h' + 'ello']() { return 'hi'; } }; obj.hello() // hi