BestCoder Round #2 1001 (简单处理)
题意:给N条信息,每个信息代表有x个人从开始的时间 到 结束的时间在餐厅就餐,
问最少需要多少座位才能满足需要。
分析:由于时间只有24*60 所以把每个时间点放到 数组a中,并标记开始的时间+x,
结束的时间 -x。最后累加比较。
如果时间点太多的时候可以把时间点放到结构体里,排序,然后依次枚举结构体。
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#define LL long long
#define rep(i, a, b)for(int i = a; i < b; i++)
const int maxn = +; using namespace std;
int a[maxn]; int main()
{
int t, n, x, h, m, ans;
cin>>t;
while(t--)
{
memset(a, , sizeof(a));
cin>>n;
while(n--)
{
scanf("%d %d:%d", &x, &h, &m);
a[h*+m] += x;
scanf("%d:%d", &h, &m);
a[h*+m] -= x;
}
ans = ;
rep(i, , maxn-)
a[i] += a[i-];
rep(i, , maxn-)
if(a[i]>ans)
ans = a[i];
cout<<ans<<endl;
}
}
BestCoder Round #2 1001 (简单处理)的更多相关文章
- 贪心 BestCoder Round #39 1001 Delete
题目传送门 /* 贪心水题:找出出现次数>1的次数和res,如果要减去的比res小,那么总的不同的数字tot不会少: 否则再在tot里减去多余的即为答案 用set容器也可以做,思路一样 */ # ...
- 暴力 BestCoder Round #41 1001 ZCC loves straight flush
题目传送门 /* m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换 ╰· */ #include <cstdio> #include < ...
- 暴力 BestCoder Round #46 1001 YJC tricks time
题目传送门 /* 暴力:模拟枚举每一个时间的度数 详细解释:http://blog.csdn.net/enjoying_science/article/details/46759085 期末考结束第一 ...
- 字符串处理 BestCoder Round #43 1001 pog loves szh I
题目传送门 /* 字符串处理:是一道水题,但是WA了3次,要注意是没有加'\0'的字符串不要用%s输出,否则在多组测试时输出多余的字符 */ #include <cstdio> #incl ...
- BestCoder Round #75 1001 - King's Cake
Problem Description It is the king's birthday before the military parade . The ministers prepared a ...
- BestCoder Round #92 1001 Skip the Class —— 字典树 or map容器
题目链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=748&pid=1001 题解: 1.trie树 关 ...
- BestCoder Round #87 1001
GCD is Funny Accepts: 524 Submissions: 1147 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 655 ...
- HDU 5776 sum (BestCoder Round #85 A) 简单前缀判断+水题
分析:就是判断简单的前缀有没有相同,注意下自身是m的倍数,以及vis[0]=true; #include <cstdio> #include <cstdlib> #includ ...
- BestCoder Round #61 1001 Numbers
Problem Description There are n numbers A1,A2....An{A}_{1},{A}_{2}....{A}_{n}A1,A2....An,yo ...
随机推荐
- 微软职位内部推荐-SDE2 (Windows driver)
微软近期Open的职位: SDE2 (Windows driver) Job title: Software Development Engineer 2 Location: Shanghai, Ch ...
- 关于 iOS 刷新效果实现的思路 和 mac软件网址推荐
有一次面试,突然有个人问了我一个问题:MJRefresh的原理是什么? 我说这种效果可以有两种方法实现: 1. UIRefreshControl 2. 通过监听scrollview的偏移量,自定义 ...
- EXT--当defaultType与items的子组件默认xtype冲突时items的子组件的xtype为panel
示例图 直接看下面示例代码: /** * 获取导入表单 * @returns {Ext.FormPanel} */ function getImportForm() { return new Ext. ...
- prim求MST
PRIM==>>MST模板 #include <iostream> using namespace std; #define typec int #define V 3 con ...
- 暑假集训单切赛第一场 CF 266E More Queries to Array(线段树+二项式展开式)
比赛时,第二题就是做的这个,当时果断没仔细考虑,直接用线段树暴力求.结果易想而知,超时了. 比赛后搜了搜题解,恍然大悟. 思路:显然用线段树,但是由于每次查询都会有变,所以不可能存储题目中的式子. ...
- Opc
http://www.tuicool.com/articles/nymUz2 http://blog.chinaunix.net/uid-20692368-id-3434001.html http:/ ...
- SDUT1574组合数的计算(组合数)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1574 这个题,比较奇怪,是用递推去做的,我试了 ...
- JAVA WEB中如何让数据库连接对开发人员完全透明?
书上的技术,确实开了眼界. 列相关测试代码如下,慢慢体会开发的模式. PropsUtil package org.smart4j.chapter2.util; import java.io.FileN ...
- 搭建网站 discuzx ecshop php
1.http://www.comsenz.com/downloads/install/discuzx下载
- Matlab程序 转C++/Opencv基于Mat 不可不知的17个函数
1.matlab中的imread相当于OpenCV中的cvLoadImage(imageName, CV_LOAD_IAMGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR): ...