POJ 1716
#include <iostream>
#include <algorithm>
#define MAXN 20005
using namespace std; int _m[MAXN]; struct node
{
int u;
int v;
}; node _node[MAXN]; bool op(node a,node b); int main()
{
//freopen("acm.acm","r",stdin);
int u;
int v;
int n;
int i;
int index = ;
cin>>n;
for(i = ; i < n; ++ i)
{
cin>>_node[i].u>>_node[i].v;
}
//cin>>u>>v;
//-- n;
sort(_node,_node+n,op);
_m[index ++] = _node[].v-;
_m[index ++] = _node[].v;
for(i = ; i < n; ++ i)
{
//cin>>u>>v;
if(_m[index-] < _node[i].u)
{
_m[index ++] = _node[i].v-;
_m[index ++] = _node[i].v;
}
else if(_m[index-] < _node[i].u)
{
_m[index ++] = _node[i].v;
}
}
cout<<index<<endl;
} bool op(node a,node b)
{
// if(a.v != b.v)
// {
return a.v < b.v;
// }
// return a.u > b.u;
}
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com
POJ 1716的更多相关文章
- 【POJ 1716】Integer Intervals(差分约束系统)
id=1716">[POJ 1716]Integer Intervals(差分约束系统) Integer Intervals Time Limit: 1000MS Memory L ...
- POJ 1201 Intervals || POJ 1716 Integer Intervals 差分约束
POJ 1201 http://poj.org/problem?id=1201 题目大意: 有一个序列,题目用n个整数组合 [ai,bi,ci]来描述它,[ai,bi,ci]表示在该序列中处于[ai, ...
- POJ 1716 Integer Intervals 差分约束
题目:http://poj.org/problem?id=1716 #include <stdio.h> #include <string.h> #include <ve ...
- poj 1716 Integer Intervals (差分约束 或 贪心)
Integer Intervals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12192 Accepted: 514 ...
- poj 1716 Integer Intervals(差分约束)
1716 -- Integer Intervals 跟之前个人赛的一道二分加差分约束差不多,也是求满足条件的最小值. 题意是,给出若干区间,需要找出最少的元素个数,使得每个区间至少包含两个这里的元素. ...
- POJ 1716 Integer Intervals
题意:给出一些区间,求一个集合的长度要求每个区间里都至少有两个集合里的数. 解法:贪心或者差分约束.贪心的思路很简单,只要将区间按右边界排序,如果集合里最后两个元素都不在当前区间内,就把这个区间内的最 ...
- poj 1716 差分约束
水水的. 给几个不等式:dis[b]-dis[a]>=2; 0<=dis[i+1]-dis[i]<=1; #include<iostream> #include< ...
- POJ 1716 Integer Intervals#贪心
(- ̄▽ ̄)-* //求一个集合,这个集合与任意一个区间的交集,需至少有两个数字 //贪心过程:按n个区间的最右值从小到大对区间进行排列, //集合首先取第一个区间的最右两个数字, //到第二个区间, ...
- 【POJ 1716】 Integer Intervals
[题目链接] 点击打开链接 [算法] 差分约束系统 [代码] #include <algorithm> #include <bitset> #include <cctyp ...
随机推荐
- 基于ArcGIS API for JavaScript的统计图表实现
感谢原作者分享:https://github.com/shevchenhe/ChartLayer,在使用的过程中,需要自己进行调试修改,主要还是_draw函数,不同的ArcGIS JS API函数有差 ...
- MongoDB的常用命令
[转]http://blog.csdn.net/ithomer/article/details/17111943 mongodb由C++编写,其名字来自humongous这个单词的中间部分,从名字可见 ...
- RUP(Rational Unified Process)统一软件过程概述
RUP是Rational公司三位杰出的软件工程大师Grady Booch,Ivar Jacobson,James Rumbaugh提出的一个软件工程过程方法.软件开发过程是将一个用户需求转化为软件系统 ...
- php正则表达式总结第1弹
介绍几个我用到的php正则表达式 1. 一篇文章的链接,我需要去掉以 /hotels/打头的链接,可用下面正则 $content = preg_replace('/<a(.*?)href=&qu ...
- PHP流程控制语句
流程控制语句分为两种(自己学到的就有俩不过在网上看还有两种) 1:条件控制语句即(if, if else , elseif , switch case) if语句不多说了,基本上大家都知道.if el ...
- SqlServer ,storedprocedure操作
USE [Role] GO /*Create a table*/ IF OBJECT_ID ('dbo.Users', 'U') IS NOT NULL DROP TABLE Users GO CRE ...
- 简单的Datatable转List,Json
这里用到了Newtonsoft.Json,下载地址:http://json.codeplex.com/ 1.根据不同的Model转为对应的List public static List<Mode ...
- IO流的异常处理
在IO流的异常处理时应该注意以下几点: 1.在外边建立引用,在Try内进行初始化(FileWriter fw = null;) 2.文件的路径使用必须是双斜杠,转义(fw = new FileWrit ...
- Visual Studio
1.必备神器http://www.cnblogs.com/stoneniqiu/p/3488546.html 2.常用快捷键http://www.cnblogs.com/TankXiao/p/3468 ...
- 怎样在cmd(命令提示符)下进行复制粘贴操作
如右图,右键命令提示符窗口的标题栏,选择属性. 选择“编辑选项”里的“快速编辑模式”,并确定之: 在弹出的应用选择提示框上选择“保存属性,供以后具有相同标题的窗口使用”: 如此你就可以 ...