2016/10/8 1001. 舞蹈室安排
来源:互联网 发布:电脑网络连接在哪里找 编辑:程序博客网 时间:2024/05/11 05:53
又是一个新的套路,首先将每个时间段按结束时间排序后,遍历每个时间段,如果开始时间比前一个的结束时间晚就可以安排下去,这样子的通过数是最多的。
#include <iostream>#include <algorithm>using namespace std;class Time{public:Time(int a = 0, int b = 0){begin = a;end = b;}int begin;int end;}time[150];bool cmp(Time a, Time b){return a.end < b.end;}int main(){int n;cin >> n;while (n--){int m;cin >> m;int total = m;while (m){int a, b;cin >> a >> b;time[total - m] = Time(a, b);m--;}sort(time, time + total, cmp);int ans = 0;Time temp;for (int i = 0; i <= total - 1; i++){if (i == 0){ans++;temp = time[i];continue;}if (time[i].begin > temp.end){temp = time[i];ans++;}}cout << ans << endl;}}
0 0
- 2016/10/8 1001. 舞蹈室安排
- 舞蹈
- 2016/8/14学习进度和安排
- 1001. 会议安排
- [sicily] 1001. 会议安排
- 1001. 会议安排
- 1001.会议安排
- 1001. 会议安排
- 1001. 会议安排
- 1001.会议安排
- 【Sicily】1001. 会议安排
- 学习计划安排 2016年底
- 2010 08 10安排
- 安排
- 舞蹈课
- 圆周舞蹈
- 舞蹈链
- (补)2016/8/16学习心得与计划安排
- 文章标题
- iOS 点击tabBar弹出登录窗口
- android屏幕适配
- swift--Swift 3.0实战:实现Dispatch once扩展
- js拖拽思想
- 2016/10/8 1001. 舞蹈室安排
- nginx+tomcat负载均衡和session复制
- Java中Timer定时器的使用
- java 知识
- 增值你的C++技能,C++成为WEB后台“颜值 ”担当(二)
- 【阿里云-云栖社区】喜欢的记得关注(每日更新)
- Eclipse 安装插件(aptana、svn 、git、Java EE、JSHint)
- 示例三和示例四和示例五
- android 状态栏颜色改变