hdu4883(贪心)

方法很巧妙,仔细看代码
/*
* this code is made by LinMeiChen
* Problem:
* Type of Problem:
* Thinking:
* Feeling:
*/
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<list>
using namespace std; typedef long long lld; typedef unsigned int ud;
#define oo 0x3f3f3f3f
#define maxn 10010
struct Node { int sit, st, ed; }per[maxn]; int sit[1444]; int main() { int T, n;
    scanf("%d", &T); while (T--) {
        scanf("%d", &n); for (int i = 1; i <= n; i++) { int st1, st2, ed1, ed2;
            scanf("%d %d:%d %d:%d", &per[i].sit, &st1, &st2, &ed1, &ed2);
            per[i].st = st1 * 60 + st2;
            per[i].ed = ed1 * 60 + ed2; }
        memset(sit, 0, sizeof sit); for (int i = 1; i <= n;i++) for (int j = per[i].st; j < per[i].ed; j++)
            sit[j] += per[i].sit; int Max = 0; for (int i = 0; i < 24 * 60; i++)
            Max = max(Max, sit[i]);
        printf("%d\n", Max); } return 0; }

你可能感兴趣的:(hdu4883(贪心))