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 ...
随机推荐
- Google的TensorFlow,微软CNTK, Amazon 的MxNet,Facebook 的Caffe2, PyTorch,国内百度的PaddlePaddle
深度学习框架竞争很激烈,而且看上去都是业界巨头在玩. 老师木:是的.一个深度学习框架一旦像Hadoop那样成为事实工业标准,就占据了人工智能各种关键应用的入口,对各类垂直应用,基于私有部署的技术服务, ...
- 关于java1.8中LocalDateTime实现日期,字符串互转小坑。
今天无聊,来看了下1.8的时间类型LocalDateTime,当想把字符串转成LocalDateTime的时候报错!! java.time.format.DateTimeParseException: ...
- 从有约束条件下的凸优化角度思考神经网络训练过程中的L2正则化
从有约束条件下的凸优化角度思考神经网络训练过程中的L2正则化 神经网络在训练过程中,为应对过拟合问题,可以采用正则化方法(regularization),一种常用的正则化方法是L2正则化. 神经网络中 ...
- codeforces 712A. Memory and Crow
2019-05-18 08:48:27 加油,加油,坚持!!! 这道题我没有想出公式推导,只是按照模拟题来做,第5个样例超时 样例超时,方法错误 https://www.cnblogs.com/ECJ ...
- 前后端分离开发,基于SpringMVC符合Restful API风格Maven项目实战(附完整Demo)!
摘要: 本人在前辈<从MVC到前后端分离(REST-个人也认为是目前比较流行和比较好的方式)>一文的基础上,实现了一个基于Spring的符合REST风格的完整Demo,具有MVC分层结构并 ...
- DropDownListFor
- Python 之 基础知识(四)
一.公共方法(列表.元组.字典以及字符串) 1.内置函数 cmp函数取消可以用比较运算符来代替,但是字典是无序的,故而不可以用比较运算符比较. 2.切片(列表.元组.字符串适用) 3.运算符 列表中直 ...
- 【SQL】分析函数功能-排序
1:排名,不考虑并列问题 row_number() 2:排名,有并列,并列后的排名不连续 rank() 3:排名,有并列,并列后的排名连续 dense_rank() 测试: SQL> creat ...
- C# 遍历对象下的 属性
foreach (System.Reflection.PropertyInfo p in users.GetType().GetProperties()) { var xx = p.Name; var ...
- ajax发送请求是图标转圈圈实现
css部分 .load-img{ //控制图标大小width:40px;height:40px;margin:100px;border-radius:50%;-webkit-animation:cir ...