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]; int main() {
scanf("%d", &T);
while (T--) {
scanf("%d%d%d%d", &n, &t, &k, &m);
for (int i = 0; i < m; i++) {
int a, b;
scanf("%d:%d%d%d", &a, &b, &p[i].p, &p[i].num);
p[i].t = a * 60 + b;
}
int ti = p[0].t, i = 0;
while (1) {
if (p[i].num == 0) {
i++;
if (i == m) break;
continue;
}
if (i == m) break;
ti = max(ti, p[i].t);
int st = ti;
int pz = p[i].p;
int have = k;
while (have < p[i].num) {
p[i].num -= have;
ti += t;
}
have -= p[i].num;
p[i].num = 0;
st = ti;
ti += t;
p[i].ans = ti;
for (int j = i + 1; p[j].t <= st && j < m && have; j++) {
if (p[j].p != pz) continue;
if (p[j].num == 0) continue;
if (p[j].num > have) {
p[j].num -= have;
have = 0;
}
else {
have -= p[j].num;
p[j].ans = ti;
p[j].num = 0;
}
}
}
for (int i = 0; i < m; i++)
printf("%02d:%02d\n", p[i].ans / 60 % 24, p[i].ans % 60);
if (T) printf("\n");
}
return 0;
}
HDU TIANKENG’s rice shop(模拟)的更多相关文章
- hdu 4884 TIANKENG’s rice shop(模拟)
# include <cstdio> # include <algorithm> # include <cstring> # include <cstdlib ...
- HDU 4884 TIANKENG’s rice shop (模拟)
TIANKENG's rice shop 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/J Description TIANKE ...
- TIANKENG’s rice shop
Problem Description TIANKENG managers a pan fried rice shop. There are n kinds of fried rice numbere ...
- 【HDOJ】4884 TIANKENG's rice shop
简单模拟,注意并不是完全按照FIFO的顺序.比如第i个人的id为k,那么就算第i+1人的id不为k,也会检查他后续的排队人是否有id为k的. #include <cstdio> #incl ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)
Thickest Burger Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 5920 Ugly Problem 【模拟】 (2016中国大学生程序设计竞赛(长春))
Ugly Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)
Football Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- HDU 4814 Golden Radio Base 模拟
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814 题目大意: 把一个正整数表示为φ进制, φ = (1+√5)/2 . 且已知: 1. φ + 1 ...
随机推荐
- Max Sum--hdoj 1003 dp
Max Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- 实现model中的文件上传FTP(一)
由于在django的model中配置了filefield或者imagefield配置了upload_to参数只能将用户上传的文件上传到项目本地,就算重定向到项目外也只是直接读取文件系统,这样对未来的项 ...
- EditPlus代码自动完成的设置
EditPlus代码自动完成的设置保存在 *.acp 文件中,可以在“工具”->“首选项”->“文件”->“文件类型及语法”中(如下图) 其中“语法文件”保存着进行语法高亮的关键词, ...
- Static variables in JavaScript
function MyClass () { // constructor function var privateVariable = "foo"; //NO:obj.privat ...
- MySQL 5.6 Reference Manual-14.2 InnoDB Concepts and Architecture
14.2 InnoDB Concepts and Architecture 14.2.1 MySQL and the ACID Model 14.2.2 InnoDB Multi-Versioning ...
- 【转载】Java实现word转pdf
最近遇到一个项目需要把word转成pdf,GOOGLE了一下网上的方案有很多,比如虚拟打印.给word装扩展插件等,这些方案都依赖于ms word程序,在java代码中也得使用诸如jacob或jcom ...
- CodeIgniter + smarty 实现widget功能
在开发过程中,经常需要widget功能,一可以隔离页面逻辑,二可以重用代码.结合smarty的plugin功能,可以方便的实现该功能. 譬如,我们的页面中可以这样写: {{extends file=' ...
- 杭电 2095 find your present (2)【位运算 异或】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2095 解题思路:因为只有我们要求的那个数出现的次数为奇数,所以可以用位运算来做,两次异或同一个数最后结 ...
- POJ 3281 Dining[网络流]
Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will c ...
- springboot实现mongodb上传下载
1.上传: private static Logger log = LoggerFactory.getLogger(MongoDbFSUtil.class); private static final ...