A.Activity planning
题目描述
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的更多相关文章
- 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 ...
- SAP BAPI一览 史上最全
全BADI一览 List of BAPI's BAPI WG Component Function module name Description Description Obj. Ty ...
- Software Engineering: 3. Project planning
recourse: "Software Engineering", Ian Sommerville Keywords for this chapter: planning sche ...
- 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 ...
- EventBus实现activity跟fragment交互数据
最近老是听到技术群里面有人提出需求,activity跟fragment交互数据,或者从一个activity跳转到另外一个activity的fragment,所以我给大家介绍一个开源项目,EventBu ...
- Android—Service与Activity的交互
service-Android的四大组件之一.人称"后台服务"指其本身的运行并不依赖于用户可视的UI界面 实际开发中我们经常需要service和activity之间可以相互传递数据 ...
- Android:Activity+Fragment及它们之间的数据交换.
Android:Activity+Fragment及它们之间的数据交换 关于Fragment与Fragment.Activity通信的四种方式 比较好一点的Activity+Fragment及它们之间 ...
- Android中Activity处理返回结果的实现方式
大家在网上购物时都有这样一个体验,在确认订单选择收货人以及地址时,会跳转页面到我们存入网站内的所有收货信息(包含收货地址,收货人)的界面供我们选择,一旦我们点击其中某一条信息,则会自动跳转到订单提交界 ...
- 报错:You need to use a Theme.AppCompat theme (or descendant) with this activity.
学习 Activity 生命周期时希望通过 Dialog 主题测试 onPause() 和 onStop() 的区别,点击按钮跳转 Activity 时报错: E/AndroidRuntime: FA ...
随机推荐
- ‘ActiveX component can’t create object解决方法
Event Type: WarningEvent Source: Health Service ScriptEvent Category: NoneEvent ID: 1Dat ...
- 云端办公是 Office系统的未来方向么 ?
云端办公是 Office系统的未来方向么 ? 话说随着互联网,HTML技术,云计算等技术的发展,越来越多的应用已经迁移到云端, 以我们熟悉的电脑游戏为例,从单机游戏,到网络游戏,再到网页游戏,基本就是 ...
- post注入及提权思路
我们这次的目标有点敏感 性感的马赛克是必须有的 登陆表单 那么我们来看看是不是存在post注入 Setp1:设置代理 Step2:账户admin密码随意 提交上去 抓个包 把抓到的包复制到本地的一 ...
- [转] linux下 /etc/profile、~/.bash_profile ~/.profile的执行过程
分类: linux 2015-03-13 16:24 1572人阅读 评论(0) 收藏 举报linuxprofile关于登录linux时,/etc/profile.~/.bash_profile等几个 ...
- 从Vue-router到html5的pushState
最近在用vue的时候突然想到一个问题 首先,我们知道vue实现的单页应用中一般不会去刷新页面,因为刷新之后页面中的vuex数据就不见了. 其次,我们也知道一般情况下,url变更的时候,比如指定loca ...
- CNN识别验证码1
之前学习python的时候,想尝试用requests实现自动登陆,但是现在网站登陆都会有验证码保护,主要是为了防止暴力破解,任意用户注册.最近接触深度学习,cnn能够进行图像识别,能够进行验证码识别. ...
- No.6 - 利用 CSS animation 制作一个炫酷的 Slider
*{ margin:; padding:; } div{ margin: auto; width: 800px; height: 681px; position: relative; overflow ...
- 《Python核心编程》第二版第三章答案
本人python新手,答案自己做的,如果有问题,欢迎大家评论和讨论! 更新会在本随笔中直接更新. 我在Windows使用python版本是2.7.0 3–10. 异常.使用类似readTextFile ...
- Java性能监控
Java性能监控 上次介绍了如何使用jvisualvm监控java,今天做进一步讲解!Java性能监控主要关注CPU.内存和线程. 在线程页中,点击线程Dump,可以生成threaddump日志,通过 ...
- SDWebImage的一些简单使用
SDWebImage是一个三方类库, 所以要使用它首先要把它引入我们的工程, 其托管在github上: https://github.com/rs/SDWebImage 有几种引入的方法, 一种是直接 ...