zoukankan      html  css  js  c++  java
  • 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
    ", p[i].ans / 60 % 24, p[i].ans % 60);
    	if (T) printf("
    ");
        }
        return 0;
    }


  • 相关阅读:
    Java calendar类学习笔记
    Anaconda 学习笔记
    第八周作业
    第七次作业
    第六周作业
    第五次作业
    用户调研方法之焦点小组
    第三周作业
    软件工作量的评估方法有哪些
    软件质量保证与测试(--作业--)
  • 原文地址:https://www.cnblogs.com/mthoutai/p/6935048.html
Copyright © 2011-2022 走看看