hdoj 4883 TIANKENG’s restaurant
来源:互联网 发布:香港青旅 知乎 编辑:程序博客网 时间:2024/05/21 08:11
TIANKENG’s restaurant
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 1574 Accepted Submission(s): 569
Problem Description
TIANKENG manages a restaurant after graduating from ZCMU, and tens of thousands of customers come to have meal because of its delicious dishes. Today n groups of customers come to enjoy their meal, and there are Xi persons in the ith group in sum. Assuming that each customer can own only one chair. Now we know the arriving time STi and departure time EDi of each group. Could you help TIANKENG calculate the minimum chairs he needs to prepare so that every customer can take a seat when arriving the restaurant?
Input
The first line contains a positive integer T(T<=100), standing for T test cases in all.
Each cases has a positive integer n(1<=n<=10000), which means n groups of customer. Then following n lines, each line there is a positive integer Xi(1<=Xi<=100), referring to the sum of the number of the ith group people, and the arriving time STi and departure time Edi(the time format is hh:mm, 0<=hh<24, 0<=mm<60), Given that the arriving time must be earlier than the departure time.
Pay attention that when a group of people arrive at the restaurant as soon as a group of people leaves from the restaurant, then the arriving group can be arranged to take their seats if the seats are enough.
Each cases has a positive integer n(1<=n<=10000), which means n groups of customer. Then following n lines, each line there is a positive integer Xi(1<=Xi<=100), referring to the sum of the number of the ith group people, and the arriving time STi and departure time Edi(the time format is hh:mm, 0<=hh<24, 0<=mm<60), Given that the arriving time must be earlier than the departure time.
Pay attention that when a group of people arrive at the restaurant as soon as a group of people leaves from the restaurant, then the arriving group can be arranged to take their seats if the seats are enough.
Output
For each test case, output the minimum number of chair that TIANKENG needs to prepare.
Sample Input
226 08:00 09:005 08:59 09:5926 08:00 09:005 09:00 10:00
Sample Output
116思路:找最大重叠区间;代码:#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int a[2000];int cmp(int x,int y){return x>y;}int main(){int t,n,j,i,h1,m1,h2,m2,s,time1,time2;scanf("%d",&t);while(t--){scanf("%d",&n);memset(a,0,sizeof(a));for(i=0;i<n;i++){scanf("%d%d:%d%d:%d",&s,&h1,&m1,&h2,&m2);time1=h1*60+m1; time2=h2*60+m2;for(j=time1;j<time2;j++){a[j]+=s;}}sort(a,a+2000,cmp);printf("%d\n",a[0]);}return 0;}
0 0
- HDOJ 4883 TIANKENG’s restaurant
- hdoj 4883 TIANKENG’s restaurant
- HDOJ 4883 TIANKENG’s restaurant
- HDOJ-4883 TIANKENG’s restaurant
- HDOJ-4883 TIANKENG’s restaurant
- HDOJ 4883 TIANKENG’s restaurant
- HDOJ TIANKENG’s restaurant
- hdoj 4883 TIANKENG’s restaurant 【贪心】
- hdoj.4883 TIANKENG’s restaurant 20140804
- hdoj 4883 TIANKENG’s restaurant 【区间覆盖】
- HDOJ 4883 TIANKENG’s restaurant(贪心)
- hdoj 4883 TIANKENG’s restaurant(贪心)
- HDOJ 4883 TIANKENG’s restaurant(思维)
- 4883 TIANKENG’s restaurant
- HDOJ 题目4883TIANKENG’s restaurant(贪心)
- 20140916 【 贪心 】 bestcoder #2 + hdoj 4883 TIANKENG’s restaurant
- HDU 4883 TIANKENG’s restaurant
- hdu 4883 TIANKENG’s restaurant
- 编程之美:第四章 数字之趣 4.10数字哑谜和回文
- CSS基础-13CSS盒子模型-概述
- android动态加载类
- hdu5329(2015多校4)--Question for the Leader
- 内存泄露调试
- hdoj 4883 TIANKENG’s restaurant
- 55 - 字符流中第一个不重复的字符
- Markdown 语法说明
- js预加载/延迟加载
- 编程之美:第四章 数字之趣 4.10_2数字哑谜和回文
- 2015 Multi-University Training Contest 4(hdu5334 - Virtual Participation)数学
- CSS基础-14CSS盒子模型-内边距
- 优化listview的方法
- 鸟哥的私房菜学习笔记九 关于文件。。。。。