题目描述
There is a collection of n activities E={1,2,..,n}, each of which requires the same resource, such as
a lecture venue, etc., and only one activity at a time Use this resource. Each activity i has a start
time of si and an end time of fi and si<fi. If the activity i is selected, it occupies resources within
the time interval [si,fi). If the interval [si,fi) does not intersect the interval [sj,fj), then the activity i is
said to be compatible with the activity j. That is, when fi<=sj or fj<=si, the activity i is compatible
with the activity j . Choose the largest collection of activities that are compatible with each other.
输入格式
The first line is an integer n;
The next n line, two integers per line, si and fi.
输出格式
Excluding mutual and compatible maximum active number.
样例输入1
4
1 3
4 6
2 5
1 7
样例输出1
2

数据范围与提示
1<=n<=1000

这道题解法与杭电今年暑假不AC解法相同,采用贪心法

代码实例

#include<stdio.h>

struct huodong
{
int begin;
int end;
} J[]; int main()
{
int n,i,j,sum,temp;
sum = ;
scanf("%d",&n);
for(i=; i<n; i++)
scanf("%d %d",&J[i].begin,&J[i].end);
for(i=; i<n-; i++)
{
for(j=; j<n-i-; j++)
{
if(J[j].end>J[j+].end)
{
temp = J[j].end;
J[j].end = J[j+].end;
J[j+].end = temp; temp = J[j].begin;
J[j].begin = J[j+].begin;
J[j+].begin = temp;
}
}
}
temp = J[].end;
for(i=; i<n; i++)
{
if(J[i].begin>=temp)
{
sum++;
temp = J[i].end;
}
}
printf("%d\n",sum);
return ;
}

A.Activity planning的更多相关文章

  1. No control record for Activity type 1000/4220/1442 in version 000 / 2017 activity planning/qty planning

    No control record for Activity type 1000/4220/1442 in version 000 / 2017 activity planning/qty plann ...

  2. SAP BAPI一览 史上最全

    全BADI一览  List of BAPI's       BAPI WG Component Function module name Description Description Obj. Ty ...

  3. Software Engineering: 3. Project planning

    recourse: "Software Engineering", Ian Sommerville Keywords for this chapter: planning sche ...

  4. Include promo/activity effect into the prediction (extended ARIMA model with R)

    I want to consider an approach of forecasting I really like and frequently use. It allows to include ...

  5. EventBus实现activity跟fragment交互数据

    最近老是听到技术群里面有人提出需求,activity跟fragment交互数据,或者从一个activity跳转到另外一个activity的fragment,所以我给大家介绍一个开源项目,EventBu ...

  6. Android—Service与Activity的交互

    service-Android的四大组件之一.人称"后台服务"指其本身的运行并不依赖于用户可视的UI界面 实际开发中我们经常需要service和activity之间可以相互传递数据 ...

  7. Android:Activity+Fragment及它们之间的数据交换.

    Android:Activity+Fragment及它们之间的数据交换 关于Fragment与Fragment.Activity通信的四种方式 比较好一点的Activity+Fragment及它们之间 ...

  8. Android中Activity处理返回结果的实现方式

    大家在网上购物时都有这样一个体验,在确认订单选择收货人以及地址时,会跳转页面到我们存入网站内的所有收货信息(包含收货地址,收货人)的界面供我们选择,一旦我们点击其中某一条信息,则会自动跳转到订单提交界 ...

  9. 报错:You need to use a Theme.AppCompat theme (or descendant) with this activity.

    学习 Activity 生命周期时希望通过 Dialog 主题测试 onPause() 和 onStop() 的区别,点击按钮跳转 Activity 时报错: E/AndroidRuntime: FA ...

随机推荐

  1. OSG3.0.1的编译

    在OSG-中国有很多关于OSG的资料,包括OSG的编译和教程. 要编译OSG首先需要准备的包: 1,OSG3.0.1源代码: 2,CMAKE: 3,OSG用到的第三方库: 4,OSG Data:OSG ...

  2. SSH端口三种转发方式

    本地转发 假设有ssh服务器B,telnet服务器C被防火墙与外界隔离,此时外部主机A无法直接访问C服务器. 此时可以通过本地转发的方式让A与C借助B服务器通过ssh协议通信. client fire ...

  3. tcp通讯中socket套接字accept和listen的关系

    今天看到一个文章,客户端的connect在服务端调用accept之前,突然想到这可以建立正常的连接么?以前从没细细的思考过listen accept connect之前的关系,带着疑问学习了一下,记录 ...

  4. JavaScript 数组遍历方法的对比

    JavaScript 发展至今已经发展出多种数组的循环遍历的方法,不同的遍历方法运行起来那个比较快,不同循环方法使用在那些场景,下面将进行比较: 各种数组遍历的方法 for 语句 ,,,] , len ...

  5. Android 之 GridView具体解释

    工作这么久以来,都是以解决需求为目标.渐渐发现这样的学习方式不好,学到的知识能立即解决这个问题,但没有经过梳理归纳. 故想系统总结下一些有趣味的知识点. 在这篇博客中想以一个样例系统解说下GridVi ...

  6. F、CSL 的神奇序列 【规律】 (“新智认知”杯上海高校程序设计竞赛暨第十七届上海大学程序设计春季联赛)

    题目传送门:https://ac.nowcoder.com/acm/contest/551/F 题目描述 CSL 有一个神奇的无穷实数序列,他的每一项满足如下关系: 对于任意的正整数 n ,有 n∑k ...

  7. selenium + python自动化测试unittest框架学习(七)随机生成姓名

    在自动化测试过程中经常要测试到添加用户的操作,每次都要输入中文,原本是找了十几个中文写成了列表,然后从列表中随机取出填入用户名文本框中,随着测试的增加,发现同名的人搜索出来一大堆,最后在网上找了个随机 ...

  8. jmeter接口测试2-断言

    接上篇 要想更好的查看接口测试结果,可以添加断言 举一个最简单的响应断言的例子 前提环境:根据接口文档可知,待测试接口返回值1,-1,-2,-3 (1)添加断言 (2)设置断言内容,看响应的内容是否含 ...

  9. HDU 1686 Oulipo (可重叠匹配 KMP)

    Oulipo Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  10. Observer(观察者)模式

    1.概述 一些面向对象的编程方式,提供了一种构建对象间复杂网络互连的能力.当对象们连接在一起时,它们就可以相互提供服务和信息. 通常来说,当某个对象的状态发生改变时,你仍然需要对象之间能互相通信.但是 ...