hdoj4883TIANKENG’s restaurant
2016-07-23 09:13
309 查看
[align=left]Problem Description[/align]
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?
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each test case, output the minimum number of chair that TIANKENG needs to prepare.
[align=left]Sample Input[/align]
[align=left]Sample Output[/align]
[/code]
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?
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each test case, output the minimum number of chair that TIANKENG needs to prepare.
[align=left]Sample Input[/align]
2 2 6 08:00 09:00 5 08:59 09:59 2 6 08:00 09:00 5 09:00 10:00
[align=left]Sample Output[/align]
11 6 代码如下: [code]#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int a[2020]; bool cmp(int x,int y) { return x>y; } int main() { int t; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); int n,q,h1,h2,m1,m2; int i,j,ts,te; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d:%d%d:%d",&q,&h1,&m1,&h2,&m2); ts=h1*60+m1;te=h2*60+m2; for(j=ts;j<=te-1;j++) a[j]+=q; } sort(a,a+1500,cmp); printf("%d\n",a[0]); } }
[/code]
相关文章推荐
- 萌妹网红陪看球,欧洲杯直播技术探秘
- 数据报的分片与组装
- centos 没有可用的网络设备
- 网络直播内容审核:拒绝黄拒绝赌拒绝黄赌毒!
- string十大热点
- awk 系列:如何使用 awk 复合表达式
- awk 系列:如何使用 awk 复合表达式
- String类比较,String类运算比较,String运算
- 3DMaxs快速导出全景图
- javascript变量undefined和null的问题
- hdu 5738 Eureka(组合数)
- RFID入门:Mifare1智能洗澡卡破解分析
- 网络直播,如何跳出组播的坑!
- UITableView的自定义cell方法总结
- hdu2102 A计划--BFS
- 防表单重复提交
- SELECT INTO 语句(W3)
- java String
- 三种简单排序算法(使用java实现)
- 包与访问控制权限及错误: 找不到或无法加载主类