标签:hdu4883
2 2 6 08:00 09:00 5 08:59 09:59 2 6 08:00 09:00 5 09:00 10:00
11 6
#include <stdio.h> #include <string.h> #include <algorithm> #define maxn 1500 using std::max_element; int arr[maxn]; int main() { int t, n, i, h, m, h2, m2, people, j; scanf("%d", &t); while(t--){ memset(arr, 0, sizeof(arr)); scanf("%d", &n); for(i = 0; i < n; ++i){ scanf("%d %d:%d %d:%d", &people, &h, &m, &h2, &m2); m += h * 60; m2 += h2 * 60; for(j = m; j < m2; ++j) arr[j] += people; } printf("%d\n", *max_element(arr, arr + 1500)); } return 0; }
#include <stdio.h> #include <string.h> #define maxn 1502 #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 int tree[maxn << 2], lazy[maxn << 2]; int max(int a, int b) { return a > b ? a : b; } void pushDown(int l, int r, int rt) { lazy[rt << 1] += lazy[rt]; lazy[rt << 1 | 1] += lazy[rt]; tree[rt << 1] += lazy[rt]; tree[rt << 1 | 1] += lazy[rt]; lazy[rt] = 0; } void pushUp(int l, int r, int rt) { tree[rt] = max(tree[rt << 1], tree[rt << 1 | 1]); } void build(int l, int r, int rt) { tree[rt] = lazy[rt] = 0; if(l == r) return; int mid = (l + r) >> 1; build(lson); build(rson); } void update(int left, int right, int val, int l, int r, int rt) { if(left == l && right == r){ lazy[rt] += val; tree[rt] += val; return; } if(lazy[rt]) pushDown(l, r, rt); int mid = (l + r) >> 1; if(right <= mid) update(left, right, val, lson); else if(left > mid) update(left, right, val, rson); else{ update(left, mid, val, lson); update(mid + 1, right, val, rson); } pushUp(l, r, rt); } int main() { //freopen("stdin.txt", "r", stdin); int t, n, i, h0, m0, h1, m1, val; scanf("%d", &t); while(t--){ build(0, 1500, 1); scanf("%d", &n); for(i = 0; i < n; ++i){ scanf("%d %d:%d %d:%d", &val, &h0, &m0, &h1, &m1); m0 += h0 * 60; m1 += h1 * 60; --m1; update(m0, m1, val, 0, 1500, 1); } printf("%d\n", tree[1]); } return 0; }
HDU4883 TIANKENG’s restaurant 【贪心】,布布扣,bubuko.com
HDU4883 TIANKENG’s restaurant 【贪心】
标签:hdu4883
原文地址:http://blog.csdn.net/chang_mu/article/details/38228131