133. Border

time limit per test: 0.25 sec. 
memory limit per test: 4096 KB

Along the border between states A and B there are N defence outposts. For every outpost k, the interval [Ak,Bk] which is guarded by it is known. Because of financial reasons, the president of country A decided that some of the outposts should be abandoned. In fact, all the redundant outposts will be abandoned. An outpost i is redundant if there exists some outpost j such that Aj<Ai and Bi<Bj. Your task is to find the number of redundant outposts.

Input

The first line of the input will contain the integer number N (1<=N<=16 000). N lines will follow, each of them containing 2 integers: Ak and Bk (0<= Ak < Bk <= 2 000 000 000), separated by blanks. All the numbers Awill be different. All the numbers Bk will be different.

Output

You should print the number of redundant outposts.

Sample Input

5
0 10
2 9
3 8
1 15
6 11

Sample Output

3
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
P seg[17000];
int n;
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%I64d%I64d",&seg[i].first,&seg[i].second);
}
sort(seg,seg+n);
ll maxn=seg[0].second;
int cnt=0;
for(int i=0;i<n;i++){
if(seg[i].second<maxn)cnt++;
else maxn=seg[i].second;
}
printf("%d\n",cnt);
}

  

快速切题 sgu133.Border 离线的更多相关文章

  1. 快速切题 sgu104. Little shop of flowers DP 难度:0

    104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM Yo ...

  2. 利用ServiceWorker实现页面的快速加载和离线访问

    Service workers 本质上充当Web应用程序与浏览器之间的代理服务器,也可以在网络可用时作为浏览器和网络间的代理.它们旨在(除其他之外)使得能够创建有效的离线体验,拦截网络请求并基于网络是 ...

  3. 快速切题sgu127. Telephone directory

    127. Telephone directory time limit per test: 0.25 sec. memory limit per test: 4096 KB CIA has decid ...

  4. 快速切题sgu126. Boxes

    126. Boxes time limit per test: 0.25 sec. memory limit per test: 4096 KB There are two boxes. There ...

  5. 快速切题 sgu123. The sum

    123. The sum time limit per test: 0.25 sec. memory limit per test: 4096 KB The Fibonacci sequence of ...

  6. 快速切题 sgu120. Archipelago 计算几何

    120. Archipelago time limit per test: 0.25 sec. memory limit per test: 4096 KB Archipelago Ber-Islan ...

  7. 快速切题 sgu119. Magic Pairs

    119. Magic Pairs time limit per test: 0.5 sec. memory limit per test: 4096 KB “Prove that for any in ...

  8. 快速切题 sgu118. Digital Root 秦九韶公式

    118. Digital Root time limit per test: 0.25 sec. memory limit per test: 4096 KB Let f(n) be a sum of ...

  9. 快速切题 sgu117. Counting 分解质因数

    117. Counting time limit per test: 0.25 sec. memory limit per test: 4096 KB Find amount of numbers f ...

随机推荐

  1. Design Pattern in Simple Examples

    Instead of defining what is design pattern lets define what we mean by design and what we mean by pa ...

  2. uchome 不从缓存中读取模板

    /source/function_common.php中的代码 //模板调用 function template($name) { global $_SCONFIG, $_SGLOBAL; if($_ ...

  3. Git入门基本操作

    由David发表在天码营 Git简介 Git不仅仅是实际项目开发中进行代码管理的神器,也是你在天码营学习需要掌握的工具. Git是一种代码版本控制工具.我们在实际项目中和天码营的学习过程中都会产生大量 ...

  4. 35. Search Insert Position(二分查找)

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  5. liunx ubuntu java 环境的配置

    手动安装jdk 一,下载jdk安装文件: jdk网站地 址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads ...

  6. spring AOP的两种代理

    本篇记录下spring AOP的两种代理,为下一篇AOP实现做下铺垫. 1.JDK动态代理  2.cglib代理 1.如果目标对象实现了接口,默认情况下会采用JDK的动态代理实现AOP2.如果目标对象 ...

  7. C#反射——模仿BeanUtil属性复制

    反射工具类请参见:https://www.cnblogs.com/threadj/p/10535796.html using System; using System.Collections.Gene ...

  8. jmeter导入csv压测

    压测csv数据源(设置为utf-8格式),jmeter不需要第一行参数名 新建一个线程组,根据压测数据调整设置需要的循环次数(测试数据有9行,设置循环次数为9) 添加http头信息 Content-T ...

  9. Python3.x:生成器简介

    Python3.x:生成器简介 概念 任何使用yield的函数都称之为生成器:使用yield,可以让函数生成一个序列,该函数返回的对象类型是"generator",通过该对象连续调 ...

  10. Sybase IQ使用过程中注意事项

    Sybase IQ使用过程中注意事项 1,字母大小写比对不敏感,也就是在值比对判断时大小写字母都一样; 2,等值,或<>判断,系统默认对等式两边比对值去右边空格再进行比较: 3,GROUP ...