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 ...
随机推荐
- windows下 berkerly db的安装配置(修正了关键步骤)
这个是我从别人的博客上找来的,亲测可用,确实解决了我当时遇到的一些问题. 首先,从http://www.oracle.com/technology/global/cn/software/product ...
- Linux中profile与bashrc的作用
文章同步发表在博主网站朗度云,传输门:http://www.wolfbe.com/detail/201608/278.html 在Linux系统上,我们会看到类似于profile和bashrc的文件, ...
- 安装WordPress详细教程指南
最近准备自己建一个个人博客,以便分享一些自己工作生活中的一些观点及经验,建博客当然选wordpress,毕竟wordpress是为博客而生的嘛.下边记录一下自己安装WordPress的详细过程指南,亦 ...
- 深入解析PHP 5.3.x 的strtotime() 时区设定 警告信息修复
在某些参考资料中是说这两个方法任选其一就可,但经我测试,必须两个方法同时使用,才不会再出现错误提示 PHP Warning: strtotime(): It is not safe to rely o ...
- 一道关于比赛胜负的Sql查询题目
以前做过一道题目,一直没有来得及总结下来.贴图: 记得以前曾经找到了两种方法,今天试了一下,还是可以的,贴出过程: 下面是具体的查询方法: 原来放的是图片,今天又练习了一下,附代码: create T ...
- linux学习之进程,线程和程序
程序.进程和线程的概念 1:程序和进 ...
- 隐藏wmware到系统托盘
[此方法是百度到的,经整理放在这里以防忘记.] 1.打开VMware Authorization Service服务.控制面板--管理工具--服务,在里面找到VMware Authorization ...
- linux文件目录下各文件简介
/bin:存放最常用命令: /boot:启动Linux的核心文件: /dev:设备文件: /etc:存放各种配置文件: /home:用户主目录: /lib:系统最基本的动态链接共享库: /mnt:一般 ...
- linux驱动路径
1. 按键驱动 \drivers\input\keyboard\utu2440_buttons.c 2. LED驱动 \drivers\char\utu2440-led.c 3. DM9000网卡驱动 ...
- SpringMVC Cache注解+Redis
依赖jar包:Xml代码 收藏代码 <!-- redis --> <dependency> <groupId ...