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. talib 中文文档(八): Momentum Indicator Functions 动量指标

    Momentum Indicator Functions ADX - Average Directional Movement Index 函数名:ADX 名称:平均趋向指数 简介:使用ADX指标,指 ...

  2. JavaScript高级程序设计第三版学习笔记(一)之数据类型区分详谈

    null.NaN.undefined三者的区别是什么? 在初次接触到JavaScript的时候,傻傻的分不清null.NaN.undefined三者到底区别何在,在实际的项目开发中也因为这个问题而困惑 ...

  3. centos7 python3 安装

    mkdir /usr/python3.5 tar -xf Python-3.5.1.tgz cd Python-3.5.1 ./configure --prefix=/usr/python3.5 ma ...

  4. python 的 import 使用规则

    对于含有 __init__.py 的目录(如adir),其实它就是一个package,它的子目录如果也包含 __init__.py,则只要将 adir 加入 sys.path,则它的字目录就不用加了, ...

  5. C#之父

    来自为知笔记(Wiz)

  6. 2.8 The Object Model -- Enumerables

    在Ember.js中,枚举是包含许多子对象的任何对象,并允许你使用Ember.Enumerable API和那些子对象一起工作.在大部分应用程序中最常见的可枚举是本地JS数组,Ember.js扩展到符 ...

  7. python面向对象编程基础

    演示了 Python 类与对象的编程基础, 包括属性.方法.继承.组合.动态创建类. python 版本: 2.7.5 class SimpleClass(object): ''' a simple ...

  8. office 2010 安装时出错 MSXML版本6.10.1129.0

    微软下载网址:https://www.microsoft.com/zh-cn/download/details.aspx?id=6276&751be11f-ede8-5a0c-058c-2ee ...

  9. 20145122 《Java程序设计》第二周学习总结

    20145122 <Java程序设计>第2周学习总结 教材学习内容总结 在大一的时候我们学习了C语言,所以对第三章的知识不是很陌生,但有些新知识需要记忆. java常用的数据类型: byt ...

  10. 2018-2019-1 20189218《Linux内核原理与分析》第二周作业

    问题一 动态库链接找不到库问题 这个问题当时确实对我造成了很大的困扰,虽然最终仍然成功用动态库链接但是问题并没有解决.现在回过头来看却觉得有点蠢,但出错的过程仍然值得总结.首先看我的目录结构: 可以看 ...