标签:
一开始以为以为是贪心, 直接wa了 ,后来好好读都体,发现时区间覆盖的问题,但是数据小,暴力应该可以过,就试了一下裸暴力,超时,后来又把暴力优化了一下才过。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int str[4000];
int main (){
int T;
scanf("%d", &T);
while(T--){
int m;
scanf("%d", &m);
int n, h1, m1, h2, m2, sum;
memset(str, 0, sizeof(str));
sum = 0;
while(m--){
scanf("%d%d:%d%d:%d", &n, &h1, &m1, &h2, &m2);
int time1 = h1 * 60 + m1;
int time2 = h2 * 60 + m2;
str[time1] += n;
str[time2] -= n;
}
for(int i = 1; i <= 1440; ++i){
str[i] += str[i - 1];
sum = max(sum, str[i]);
}
printf("%d\n", sum);
}
return 0;
}
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main (){
int T;
scanf("%d", &T);
int str[11000];
while(T--){
int m;
scanf("%d", &m);
int n, h1, m1, h2, m2, sum;
memset(str, 0, sizeof(str));
sum = 0;
while(m--){
scanf("%d%d:%d%d:%d", &n, &h1, &m1, &h2, &m2);
int time1 = h1 * 60 + m1;
int time2 = h2 * 60 + m2;
for(int i = time1; i < time2; ++i){
str[i] += n;
sum = max(str[i], sum);
}
}
printf("%d\n", sum);
}
return 0;
} 版权声明:本文为博主原创文章,未经博主允许不得转载。
HDU 4883--TIANKENG’s restaurant【区间覆盖 && 暴力】
标签:
原文地址:http://blog.csdn.net/hpuhjh/article/details/47178663