题目描述
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. Javascript 中 true 和 false

    "" == false // true "0" == false // true "" == "0" //false 以 ...

  2. Python简介及编码

    首先Python是一种语言,因此根据其实现的不同,有Cpython, Jython, IronPython, Pypy等. Python执行流程 $ python /home/hello.py     ...

  3. Economy a Two-Edged Sword for Democrats

    2017-05-03 12:05:07 https://www.usnews.com/news/blogs/ken-walshs-washington/2014/10/03/economy-a-two ...

  4. [Assignment] C++1

    作业要求: 给出圆半径求面积. 使用cin和cout.用多个源文件处理函数. →代码在这里

  5. 异常处理与MiniDump详解(3) SEH(Structured Exception Handling)

    write by 九天雁翎(JTianLing) -- blog.csdn.net/vagrxie 讨论新闻组及文件 一.   综述 SEH--Structured Exception Handlin ...

  6. 中石油大学统考(大学英语B)押题笔记

    二. 词汇与结构 1. I will.意为“我会的”,固定搭配. 2. get tired of 是词组“对…厌烦了”的意思. 3. — ________ is your girl friend li ...

  7. (转)Win10下PostgreSQL10与PostGIS安装

    版权声明:本文为博主原创文章,欢迎转载. https://blog.csdn.net/LWJ285149763/article/details/79380643 最近在使用矢量数据,因此需要用空间数据 ...

  8. myeclipse解决JSP文件里script背景颜色的调整

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/UP19910522/article/details/27971401 1导入MyEclipse的主题 ...

  9. mysql 数据增删改查基本语句

    增: insert insert into 表名(字段1,字段2,字段3......字段N) values(值1,值2,值3): 如果不申明插入那些字段,则默认所有字段. 如果一次可以插入多条数据 可 ...

  10. C++ —— 小操作

    判断一个浮点数是否是整数: #include <iostream> using namespace std; int main() { ); if (l == (int)l) { //.. ...