序号:1972
Time Limit:1s Memory Limit:128MB
节目安排
输入数据第一行只有一个整数n(n<=100)n(n<=100),表示你喜欢看的节目的总数,然后是nn行数据,每行包括两个数据Tis,Tie(1<=i<=n)Tis,Tie(1<=i<=n),分别表示第ii个节目的开始和结束时间,为了简化问题,每个时间都用一个非负整数表示。
输出能完整看到的电视节目的个数。
输入 #1
- 12
- 1 3
- 3 4
- 0 7
- 3 8
- 15 19
- 15 20
- 10 15
- 8 18
- 6 12
- 5 10
- 4 14
- 2 9
输出 #1
5
- #include
- #include
- #include
- using namespace std;
- struct node{
- int start;
- int end;
- }a[100];
- int compare(node a,node b){
- return a.end
- }
- int main(){
- int n,i,f,flag;
- while(scanf("%d",&n)&&n){
- f=1;
- for(i=0;i
- scanf("%d%d",&a[i].start,&a[i].end);
- }
- sort(a,a+n,compare);
- flag=a[0].end;
- for(i=1;i
- if(a[i].start>=flag){
- f++;
- flag=a[i].end;
- }
- }
- printf("%d",f);
- return 0;
- }
- }
-
相关阅读:
【小黑嵌入式系统第八课】初识PSoC Creator™开发——关于PSoC Creator&下载、创建项目、单片机中的hello world(点亮一个led)
ImportError: cannot import name ‘secure_write‘ from ‘jupyter_core.paths‘解决方案
【高等数学基础进阶】多元函数微分学-重极限、连续、偏导数、全微分
【云原生--Kubernetes】配置管理
抄写Linux源码(Day13:从 MBR 到 C main 函数 (2:研究 setup.s) )
Unity URP14.0 自定义后处理框架
新手投资如何分配股票仓位?诺奖得主的秘诀是什么?| 附代码【邢不行】
智能合约经典漏洞案例,xSurge 重入漏洞+套利 综合运用
在Jupyter Notebook中使用Matplotlib(Anaconda3)
【附源码】计算机毕业设计JAVA客户台账管理
-
原文地址:https://blog.csdn.net/yys365/article/details/126095235