[贪心][DP][Ural 1203]Scientific Conference
来源:互联网 发布:边境牧羊犬多聪明 知乎 编辑:程序博客网 时间:2024/05/16 14:56
1203. Scientific Conference
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
Functioning of a scientific conference is usually divided into several simultaneous sections. For example, there may be a section on parallel computing, a section on visualization, a section on data compression, and so on.
Obviously, simultaneous work of several sections is necessary in order to reduce the time for scientific program of the conference and to have more time for the banquet, tea-drinking, and informal discussions. However, it is possible that interesting reports are given simultaneously at different sections.
A participant has written out the time-table of all the reports which are interesting for him. He asks you to determine the maximal number of reports he will be able to attend.
Input
The first line contains the number 1 ≤ N ≤ 100000 of interesting reports. Each of the next N lines contains two integers Ts and Te separated with a space (1 ≤ Ts < Te ≤ 30000). These numbers are the times a corresponding report starts and ends. Time is measured in minutes from the beginning of the conference.
Output
You should output the maximal number of reports which the participant can attend. The participant can attend no two reports simultaneously and any two reports he attends must be separated by at least one minute. For example, if a report ends at 15, the next report which can be attended must begin at 16 or later.
Sample
53 41 56 74 51 3
3
思路:活动安排问题,将结束的时间排个序,然后与开始的时间比较
#include<stdio.h>#include<algorithm>using namespace std;struct hui{int s,e;}wuli[100086];bool cmp(hui a,hui b){return a.e<b.e;} int main(){int n,t;scanf("%d",&n);int i;for(i=1;i<=n;i++){scanf("%d%d",&wuli[i].s,&wuli[i].e);}sort(wuli+1,wuli+1+n,cmp);int et=wuli[1].e;int counter=1;for(i=2;i<n;i++){if(wuli[i].s>et){counter++;et=wuli[i].e;}}printf("%d\n",counter);}
0 0
- URAL 1203 Scientific Conference(贪心 || DP)
- [贪心][DP][Ural 1203]Scientific Conference
- URAL 1203 Scientific Conference (贪心)
- URAL 1203 Scientific Conference (贪心 + 优化)
- URAL 1203Scientific Conference dp练习
- Ural 1203 Scientific Conference
- URAL 1203 Scientific Conference
- Ural 1203 Scientific Conference
- ural 1203. Scientific Conference(贪心or dp)
- Ural 1203. Scientific Conference
- ural 1203. Scientific Conference
- CSU1065-Scientific Conference-贪心
- 1203. Scientific Conference 解题报告 URAL
- ural 1203. Scientific Conference(dp)给定N个区间,求最大的不相交的区间数
- Scientific Conference
- CSU 1065 Scientific Conference 贪心(基本的调度问题)
- Timus 1203. Scientific Conference
- CSU Scientific Conference
- NYOJ 325 &&NYOJ 456
- HDU1056 HangOver 水题
- 伸展树(转载)
- 设计模式之中介者模式
- 二叉树
- [贪心][DP][Ural 1203]Scientific Conference
- JavaWeb中路径问题
- NYOJ 306 走迷宫(DFS+二分法)
- actionresult的返回类型
- ubuntu14.04环境下安装配置OpenCV3.2+anaconda2(Python2.7)
- 深入浅出搜索架构引擎、方案与细节(上)
- NYOJ 304 节能(DP)
- python学习1 详细记录python的range()函数用法
- [Codevs] 3044 矩形面积求并(离散化)