hdu 4883 思维题

链接:http://acm.hdu.edu.cn/showproblem.php?pid=4883

TIANKENG’s restaurant

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 566    Accepted Submission(s): 267

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.

Output

For each test case, output the minimum number of chair that TIANKENG needs to prepare.

Sample Input

2

2

6 08:00 09:00

5 08:59 09:59

2

6 08:00 09:00

5 09:00 10:00

Sample Output

11

6

Source

BestCoder Round #2

---------------------------------------------------------------------

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4
 5 int main()
 6 {
 7     int str[1445];
 8     int n,m,i,j,k,t,num,hh1,hh2,mm1,mm2;
 9     scanf("%d",&n);
10     while(n--)
11     {
12         memset(str,0,sizeof(str));
13         scanf("%d",&m);
14         for(i=0;i<m;i++)
15         {
16             scanf("%d %d:%d %d:%d",&num,&hh1,&mm1,&hh2,&mm2);
17             hh1=hh1*60+mm1;
18             hh2=hh2*60+mm2;
19             str[hh1]+=num;
20             str[hh2]-=num;//printf("%d%d^^",str[hh1],str[hh2]);
21         }
22         int maxx=0,cas=0;
23         for(i=0;i<=1440;i++)
24         {
25             cas+=str[i];
26             if(cas>maxx)
27             {
28                 maxx=cas;
29             }
30         }
31         printf("%d\n",maxx);
32     }
33     return 0;
34 }

hdu 4883 思维题

时间: 2024-08-06 01:31:21

hdu 4883 思维题的相关文章

hdu 4810 思维题+二进制位规律+异或规律 213南京现场赛题

http://acm.hdu.edu.cn/showproblem.php?pid=4810 以前做过一些涉及异或的题,化为二进制形式,然后统计0,1个数是一种很常见的处理方法,但是在做这个题的时候居然没尝试,脑残啊...... 一开始看5s时限,感觉稍微暴力一点应该可以,于是YY的O(n^3)算法但是没去实现,明显超时啊,大致就是通过C(n,1)的组合可以在O(n^2)内处理出C(n,2)的组合,在通过C(n,2)处理出C(n,3)的组合....但是C(n,2)已经是n^2个数了,所以算法是O

hdu 5014 思维题/推理

http://acm.hdu.edu.cn/showproblem.php?pid=5014 从小数开始模拟找方法规律,然后推广,尤其敢猜敢尝试,错了一种思路继续猜-----这是一种很重要的方法啊 这道题还是从小数开始模拟,我是根据16以内的找的规律 根据 2^k---2^k-1 2^k+1---2^k-2 ... 这样陪下去 当2^k==n的时候, 从2^(k-1)按同样的方法配下去, WA了很久,是lower_bound用错了 不过没明白为啥  换成upper_bound也可以AC....但

Just Random HDU - 4790 思维题(打表找规律)分段求解

Coach Pang and Uncle Yang both love numbers. Every morning they play a game with number together. In each game the following will be done:  1. Coach Pang randomly choose a integer x in [a, b] with equal probability.  2. Uncle Yang randomly choose a i

朋友HDU - 5963 (思维题) 三种方法

传送门 题目描述 输入 输出 样例输入 2 2 3 1 2 0 0 1 1 2 1 1 0 2 4 11 1 2 1 2 3 1 3 4 0 0 1 0 2 0 3 0 4 1 2 1 0 0 1 0 2 0 3 1 3 4 1 0 3 0 4 Sample Input 样例输出 Boys win! Girls win! Girls win! Boys win! Girls win! Boys win! Boys win! Girls win! Girls win! Boys win! Girl

hdu 5491 思维题

#include<stdio.h> #include <math.h> #include <algorithm> #include <math.h> #include <string.h> #include <bitset> #include <iostream> using namespace std; #define LL long long void out(LL x) { bitset<32>s(x);

Fang Fang HDU - 5455 (思维题)

Fang Fang says she wants to be remembered. I promise her. We define the sequence FF of strings. F0 = ''f",F0 = ''f", F1 = ''ff",F1 = ''ff", F2 = ''cff",F2 = ''cff", Fn = Fn?1 + ''f", for n > 2Fn = Fn?1 + ''f", fo

hdu 4972 A simple dynamic programming problem (转化 乱搞 思维题) 2014多校10

题目链接 题意:给定一个数组记录两队之间分差,只记分差,不记谁高谁低,问最终有多少种比分的可能性 分析: 类似cf的题目,比赛的时候都没想出来,简直笨到极点..... 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <cmath> 6 #include <vector> 7 #include &

hdu 4932 /bestcoder B题 #4 /思维题

题意:给一个数列(整数),用一些不相交的区间去覆盖(只能是用端点去覆盖,端点可以交).而且区间出度相等.求最大区间长度. 开始一下就敲了,枚举每个区间长度,判断合法,更新最大.但是后来一看小数,感觉不行,改为二分,后来还是挂了... 赛后才知道,二分的时候,答案必需要满足单调性啊,这里小的数据不行,大的数据可以行!如 0 1 5 6 10, 3不行,4行. 后来才知道,枚举时,每个差值的一半也是可以的:仔细想想很容易证明.(水,坑) #include<iostream> #include<

HDU 4883 (BC#2 1001题)TIANKENG’s restaurant(水)

题目地址:HDU 4883 唉..最近得了一种惯性..刚学了什么就碰到个类似的就想用刚学的算法...原来这题如此简单..当时真是想多了.... 只要在需要变化的点上设置一个值,是增多少还是减多少.然后当遍历过来的时候加上或减去这个值就行了... 代码如下: #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h>