#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的更多相关文章

  1. 【POJ 1716】Integer Intervals(差分约束系统)

    id=1716">[POJ 1716]Integer Intervals(差分约束系统) Integer Intervals Time Limit: 1000MS   Memory L ...

  2. POJ 1201 Intervals || POJ 1716 Integer Intervals 差分约束

    POJ 1201 http://poj.org/problem?id=1201 题目大意: 有一个序列,题目用n个整数组合 [ai,bi,ci]来描述它,[ai,bi,ci]表示在该序列中处于[ai, ...

  3. POJ 1716 Integer Intervals 差分约束

    题目:http://poj.org/problem?id=1716 #include <stdio.h> #include <string.h> #include <ve ...

  4. poj 1716 Integer Intervals (差分约束 或 贪心)

    Integer Intervals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12192   Accepted: 514 ...

  5. poj 1716 Integer Intervals(差分约束)

    1716 -- Integer Intervals 跟之前个人赛的一道二分加差分约束差不多,也是求满足条件的最小值. 题意是,给出若干区间,需要找出最少的元素个数,使得每个区间至少包含两个这里的元素. ...

  6. POJ 1716 Integer Intervals

    题意:给出一些区间,求一个集合的长度要求每个区间里都至少有两个集合里的数. 解法:贪心或者差分约束.贪心的思路很简单,只要将区间按右边界排序,如果集合里最后两个元素都不在当前区间内,就把这个区间内的最 ...

  7. poj 1716 差分约束

    水水的. 给几个不等式:dis[b]-dis[a]>=2;  0<=dis[i+1]-dis[i]<=1; #include<iostream> #include< ...

  8. POJ 1716 Integer Intervals#贪心

    (- ̄▽ ̄)-* //求一个集合,这个集合与任意一个区间的交集,需至少有两个数字 //贪心过程:按n个区间的最右值从小到大对区间进行排列, //集合首先取第一个区间的最右两个数字, //到第二个区间, ...

  9. 【POJ 1716】 Integer Intervals

    [题目链接] 点击打开链接 [算法] 差分约束系统 [代码] #include <algorithm> #include <bitset> #include <cctyp ...

随机推荐

  1. <Linux系统hostname命令详解>

    hostname命令的用法的小知识我们都知道hostname命令是查看主机名和修改主机名的. [root@apache ~]# hostname  //查看本机的主机名apache.example.c ...

  2. Atan2

    在三角函数中,两个参数的函数atan2是正切函数的 一个变种.对于任意不同时等于0的实参数x和y,atan2(y,x)所表达的意思是坐标原点为起点,指向(x,y)的射线在坐标平面上与x轴正方向之间 的 ...

  3. 为msysgit增加vim语法高亮文件

    在win7下装了msysgit,今天我遇到一个不爽的问题,打开git bash,用vim打开一个xml文件 结果都是黑屏的,没语法高亮,这个必须不能忍啊,我找到msysgit的安装目录,发现Vim73 ...

  4. javascript refresh page 几种页面刷新的方法

    Javascript刷新页面的几种方法:1    history.go(0) 2    location.reload() 3    location=location 4    location.a ...

  5. R简易入门(二)

    本文内容来源:https://www.dataquest.io/mission/128/working-with-data-frames 本文摘要:简单介绍一下用R处理数据   原始数据展示(这是一份 ...

  6. Spark 大数据平台

    Apache Spark is an open source cluster computing system that aims to make data analytics fast - both ...

  7. perl中shift 和unshift 操作

    ##################################################################### unshift 和shift 对一个数组的开头进行操作(数组 ...

  8. 内部技术分享的 PPT

    本文的基础是搞了一次内部的技术分享,在此也分享一下本次的PPT的一些内容.先列一下大概内容吧. EF-Code First API(WCF.WebAPI) Xaml MVVM AOP Xamarin. ...

  9. elipse+pydev+python开发arcgis脚本程序

    环境配置参考:http://www.cnblogs.com/halfacre/archive/2012/07/22/2603848.html 添加arcpy类库.arctoolbox.arcgis-b ...

  10. mouse_driver

    1:function.h #ifndef FUNCTION_H#define FUNCTION_H #define DRIVER_FUNCTION_ADD_DEVICE#define DRIVER_F ...