[SDUT](2073)活动选择问题 ---贪心
来源:互联网 发布:龙瞎皮肤多少钱淘宝 编辑:程序博客网 时间:2024/06/04 19:31
活动选择问题
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic Discuss
Problem Description
sdut 大学生艺术中心每天都有n个活动申请举办,但是为了举办更多的活动,必须要放弃一些活动,求出每天最多能举办多少活动。
Input
输入包括多组输入,每组输入第一行为申请的活动数n(n<100),从第2行到n+1行,每行两个数,是每个活动的开始时间b,结束时间e;
Output
输出每天最多能举办的活动数。
Example Input
1215 2015 198 1810 154 146 125 102 93 80 73 41 3
Example Output
5
解题新知:其实就是暑假不AC,练练sort函数~\(≧▽≦)/~
AC代码:
#include<iostream>#include<algorithm>using namespace std;struct node{ int s; int e;};bool cmp(node a,node b){ return a.e<b.e;}int main(){ int n; node time[105]; while(cin>>n) { for(int i=0;i<n;i++) { cin>>time[i].s>>time[i].e; } sort(time,time+n,cmp); int sum=1; int End=time[0].e; for(int i=1;i<n;i++) { if(time[i].s>=End) { End=time[i].e; sum++; } } cout<<sum<<endl; } return 0;}
阅读全文
0 0
- 贪心法 2073--> 活动选择问题 SDUT
- [SDUT](2073)活动选择问题 ---贪心
- SDUT 贪心 活动选择问题
- SDUT 2073----活动选择问题
- sdut 2073 活动选择问题
- SDUT 贪心法 活动选择
- sdut 活动选择问题
- 2073 活动选择问题【贪心】
- sdut.acm活动选择问题
- 活动选择问题 (sdut oj)
- 活动选择问题 贪心
- 贪心:活动选择问题
- 活动选择问题(贪心)
- 贪心算法例题:2073活动选择问题
- 贪心算法活动选择问题
- 贪心算法---活动选择问题
- 贪心法 活动选择问题
- 贪心算法-活动选择问题
- 设计模式 2-23 工厂模式
- Android开发笔记:基础控件之RadioGroup用法
- Zookeeper和分布式环境中的假死脑裂问题(转发)
- 基于Hexo在Mac上搭建自己的个人博客
- 开始写博客
- [SDUT](2073)活动选择问题 ---贪心
- informatica9 安装下载,安装教程 介质(文章和视频教程)(csdn讲师:Array)
- 使用navicat连接oracle时,解决报错listener does not currently know of service requested in
- Ajax动态加载下拉列表中的值
- Spring Boot 在localhost域奇怪的404问题(Mac book pro)
- vue——v-cloak与过度效果混合使用的坑
- RecyclerView实现条目Item拖拽排序与滑动删除
- java switch 支持 String
- jQuery 文档操作