HDOJ 4883 TIANKENG’s restaurant(思维)
来源:互联网 发布:php unset函数 编辑:程序博客网 时间:2024/04/30 22:55
TIANKENG’s restaurant
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 2393 Accepted Submission(s): 884
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
Source
BestCoder Round #2
Recommend
liuyiding | We have carefully selected several similar problems for you: 5733 5732 5731 5730 5729
思路:
这个题目起初是用的结构体排序折腾很久,最后看题解换一种思路,就是转换为分钟的数组,然后记录就行了。
代码:
#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm>#define MYDD 10103using namespace std;bool cmp(int x,int y) { return x>y;}int MAX(int x,int y) { return x>y? x:y;}int main() { int t,n; int liu,ch,cm,lh,lm; int ans[24*60+4];//用于记录当前分钟的人数 scanf("%d",&t); while(t--) { memset(ans,0,sizeof(ans)); scanf("%d",&n); while(n--) { scanf("%d %d:%d %d:%d",&liu,&ch,&cm,&lh,&lm); int come=ch*60+cm;//一小时60分钟,自己弄成24,也是够了 int left=lh*60+lm-1;//防止时间的重复 for(int j=come; j<=left; j++) { ans[j]+=liu; // printf("****%d*****%d\n",j,ans[j]); } } sort(ans,ans+24*60+4,cmp); printf("%d\n",ans[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-4883 TIANKENG’s restaurant
- HDOJ 4883 TIANKENG’s restaurant
- HDOJ TIANKENG’s restaurant
- HDOJ 题目4883TIANKENG’s restaurant(贪心)
- hdoj 4883 TIANKENG’s restaurant 【贪心】
- hdoj.4883 TIANKENG’s restaurant 20140804
- hdoj 4883 TIANKENG’s restaurant 【区间覆盖】
- HDOJ 4883 TIANKENG’s restaurant(贪心)
- 4883 TIANKENG’s restaurant
- HDU 4883 TIANKENG’s restaurant (贪心)
- hdu 4883 TIANKENG’s restaurant(思路)
- 20140916 【 贪心 】 bestcoder #2 + hdoj 4883 TIANKENG’s restaurant
- Service的使用(二)启动服务与IntentService
- 杭电Problem 1872 稳定排序
- Qt qml 实现类似手机电话薄联系人首字母查找
- Remove Nth Node From End of List leetcode java
- 7/20android培训第10天
- HDOJ 4883 TIANKENG’s restaurant(思维)
- Jenkins入门系列--Jenkins安装与配置
- uva 11572 唯一的雪花(滑动窗口)
- 漫步微积分八——多项式求导
- 欢迎使用CSDN-markdown编辑器
- Groovy学习
- 几种中文乱码的解决方法
- NYOJ-56
- 读书笔记:Effective C++(二)