HDU TIANKENG’s rice shop(模拟)
Posted mthoutai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 4886 TIANKENG’s restaurant(Ⅱ) hash+dfs
hdu 4122 Alice's mooncake shop
hdu 4122 Alice's mooncake shop (线段树)