UVALive 6606 Meeting Room Arrangement 【搜索】
2014-08-20 14:35
369 查看
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4617
题目大意:现在有一个房间,租用的时间是1~12点,已知一些会议的开始时间和结束时间,问最多可以开多少会议(会议时间不可以冲突)。
对结束时间进行一个排序,然后查找即可。
题目大意:现在有一个房间,租用的时间是1~12点,已知一些会议的开始时间和结束时间,问最多可以开多少会议(会议时间不可以冲突)。
对结束时间进行一个排序,然后查找即可。
#include<iostream> #include<algorithm> #include<stdio.h> using namespace std; #define maxn 105 struct node { int s, e; }; bool cmp(node x, node y){ return x.e<y.e; } int main () { int T; scanf("%d",&T); node time[maxn]; while(T--) { int pos=0,ans=0; while(1){ scanf("%d%d",&time[pos].s,&time[pos].e); if(time[pos].s==0&&time[pos].e==0) break; pos++; } sort(time,time+pos,cmp); int ee = 0; for(int i=0;i<pos;i++){ if(time[i].s>=ee){ ans++; ee = time[i].e; } } printf("%d\n",ans); } }
相关文章推荐
- G - Meeting Room Arrangement UVALive - 6606——动态规划
- UVALive_6606_Meeting Room Arrangement(最大独立集)
- UVaLive 6609 Meeting Room Arrangement (贪心,区间不相交)
- UVA Meeting Room Arrangement - 贪心
- UVALive 6255 Kingdoms --状态搜索
- UVA 1063|11318|UVALive 3807|Marble Game|搜索
- uvalive 5881 map + 搜索记录
- uvalive 3971 - Assemble(二分搜索 + 贪心)
- 例题1.8 彩色立方体 Colored Cubes UVALive - 3401 暴力打表+暴力搜索+贪心
- UVALive - 3902 Network 无根树转为有跟树+搜索+贪心
- UVALive 3565 Bit Compressor (搜索)
- UVALive 4763 Sudoku Extension(搜索)
- UVALive 3942 (LA 3492) Remember the Word Trie树 + 记忆化搜索
- UVALive 6902 Three Squares(二分 + 搜索)
- UVALive 6470 Chomp --记忆化搜索
- UVALive 5966 Blade and Sword -- 搜索(中等题)
- UVALive 7416 Bringing Order to Disorder(搜索)
- UVALive 5833 Moles(笛卡尔树+搜索+hash)
- UVALive 3907 (LA 3907) Puzzle AC自动机 + 搜索DP 记录路径
- UVALIVE 5893 计算几何+搜索