题目链接

Problem Statement

Codenation is sending N of its employees to a High Profile Business Conference and the goal is to cover maximum number of presentations, to create maximum business opportunities. It has a list of all the presentations with their start and end times. You need to help Codenation decide an optimal allocation.

The start and end times of a presentation are provided to you as a single string and are separated by a space.

Each time is given in the form HH:MM and represents a time between 08:00 in the morning and 08:00 in the evening inclusive.

Input Format
First line contains an integer N (number of employees). 
The second line contains integer P (number of presentations). 
P lines follow each having conference start time and end time separated by a space.

Constraints
1≤N≤10 
1≤P≤50 
Each of P lines will contain 11 characters in the form HH:MM HH:MM
Each HH:MM will represent a time between 8 am and 8 pm inclusive. 
Each MM will be between 00 and 59, inclusive. 
In each element of presentations the second time will be strictly later than the first.

Output Format
Print the maximum number of presentations that can be attended.

Note: We can assume the time taken for going from one presentation to another is negligible; i.e. if end time of one presentation is same time as start time of another, a single person can cover both presentations from start to end.

Sample Input#00

3
5
08:00 08:00
08:00 08:00
08:00 08:00
08:00 08:00
08:00 08:00

Sample Output#00

3

Explanation#00

All these presentations last all day long. Nobody can cover more than one.

Sample Input#01

2
5
09:00 08:00
08:00 12:00
12:00 08:00
08:00 08:00
08:00 08:00

Sample Output#01

3

Explanation#01
One person can cover the 8-12 presentation and the 12-8 presentation. The other person can cover one of the all-day presentation.

Sample Input#02

1
5
08:00 01:00
08:25 12:50
12:00 12:30
12:30 08:00
08:00 08:00

Sample Output#02

2
题目分析:
  实际上是个作业安排问题的扩展问题。即给定N个会议,每个会议有开始时间和结束时间,有M个人,问M个人最多总共可以参加多少场会议。
如果M=1,当然就是按照结束时间排序,即可。
这里只需要简单的变形一下,设b[j]为第j个人当前所位于的时间点(初始都为0), 对于第i个会议,如果有多个满足条件的人,选择b[j]最大的那个。
附上代码:
 #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std; typedef pair<int, int> pii;
#define F first
#define S second int main() {
int N, P;
scanf("%d %d", &N, &P);
pii t[];
for (int i = ; i < P; i++) {
int h1, m1, h2, m2, start, end;
scanf("%d:%d %d:%d", &h1, &m1, &h2, &m2);
start = (h1 >= ? (h1 - ) * : (h1 + ) * ) + m1;
end = ((h2 > || h2 == && m2) ? (h2 - ) * : (h2 + ) * ) + m2;
t[i] = pii(end, start);
}
sort(t, t + P);
for (int i = ; i < P; i++) cerr << t[i].S << ' ' << t[i].F << endl;
int ans = ;
int now[] = {};
for (int i = ; i < P; i++) {
int x = -, last = -;
for (int j = ; j < N; j++) {
if (t[i].S >= now[j]) {
if (now[j] > last) {
x = j;
last = now[j];
}
}
}
if (x != -) {
ans++;
now[x] = t[i].F;
}
}
printf("%d\n", ans); return ;
}
												

Make the Most (Hackerrank Codeagon)的更多相关文章

  1. 日常小测:颜色 && Hackerrank Unique_colors

    题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...

  2. HackerRank "Square Subsequences" !!!

    Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the soluti ...

  3. HackerRank "Minimum Penalty Path"

    It is about how to choose btw. BFS and DFS. My init thought was to DFS - TLE\MLE. And its editorial ...

  4. HackerRank "TBS Problem" ~ NPC

    It is marked as a NPC problem. However from the #1 code submission (https://www.hackerrank.com/Charl ...

  5. HackerRank Extra long factorials

    传送门 今天在HackerRank上翻到一道高精度题,于是乎就写了个高精度的模板,说是模板其实就只有乘法而已. Extra long factorials Authored by vatsalchan ...

  6. HackerRank "Lucky Numbers"

    Great learning for me:https://www.hackerrank.com/rest/contests/master/challenges/lucky-numbers/hacke ...

  7. HackerRank "Playing with numbers"

    This is 'Difficult' - I worked out it within 45mins, and unlocked HackerRank Algorithm Level 80 yeah ...

  8. HackerRank "The Indian Job"

    A sly knapsack problem in disguise! Thanks to https://github.com/bhajunsingh/programming-challanges/ ...

  9. HackerRank "Array and simple queries" !

    The most interesting, flexible and juicy binary tree problem I have ever seen. I learnt it from here ...

随机推荐

  1. fiddler设置抓取HTTPS协议数据包

    1.打开工具里的选项 2.选择弹窗中的HTTPS选项,如下图进行勾选 3.若浏览器显示不安全链接则需要添加证书 提示如下点击确定证书安装成功,可以查看安装的证书,点击Action 下图即可查看fidd ...

  2. (转)Android 自定义标题栏(title栏)

    转:http://blog.csdn.net/jamin0107/article/details/6715678 第一步,向实现自定义标题栏,需要在onCreate方法里这样写 requestWind ...

  3. .NETFramework-Web.Mvc:HttpXxxAttribute-目录

    ylbtech-.NETFramework-Web.Mvc:HttpXxxAttribute-目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返 ...

  4. Keras+Yolo 目标检测

    参考:https://www.cnblogs.com/tensorflownews/p/8922359.html Github:https://github.com/qqwweee/keras-yol ...

  5. 如何上传文件到git

    具体有三大步骤: 一.创建新的仓库 二.本地仓库 三.git命令上传(需要下载git) 一.创建新的仓库   二.本地仓库 其实这个本地仓库就是文件的所在地,在哪都可以 三.git命令上传(需要下载g ...

  6. PAT甲级——A1134 Vertex Cover【25】

    A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at le ...

  7. wpf datepicker 样式

    在项目中用到的 <Style TargetType="{x:Type DatePicker}"> <Setter Property="Foregroun ...

  8. 使用Flume+Kafka+SparkStreaming进行实时日志分析

    每个公司想要进行数据分析或数据挖掘,收集日志.ETL都是第一步的,今天就讲一下如何实时地(准实时,每分钟分析一次)收集日志,处理日志,把处理后的记录存入Hive中,并附上完整实战代码 1. 整体架构 ...

  9. 【HZOI2015】帕秋莉的超级多项式

    题面 题目分析 超级模板题: 多项式乘法 多项式求逆 多项式开根 多项式求导 多项式求积分 多项式求对数 多项式求自然对数为底的指数函数 多项式快速幂 代码实现 #include<iostrea ...

  10. Jmeter性能测试 入门【转】

    Jmeter性能测试 入门[转] Jmeter是一款优秀的开源测试工具, 是每个资深测试工程师,必须掌握的测试工具,熟练使用Jmeter能大大提高工作效率. 熟练使用Jmeter后, 能用Jmeter ...