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. 爬虫Scrapy框架

    安装scrapy 在安装过程中报错:解决方案 通过在https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted,然后下载: CP后是python 版本,32 ...

  2. scrapy框架(2)

    一.使用scrapy框架发送post请求 1.需求一:使用scrapy发送百度翻译中的ajax请求 创建一个项目,如下目录,修改settings.py文件中的 "ROBOTSTXT_OBEY ...

  3. input输入框type=file时accept中可以限制的文件类型(转载)

    转载自: input type=file accept中可以限制的文件类型 在上传文件的时候,需要限制指定的文件类型. <input type="file" accept=& ...

  4. java8工具类使用

    1:map的使用 computeIfPresent ,如果键已经存在,将键和值作为参数传到函数式中,计算返回新的值 import java.util.HashMap; import java.util ...

  5. Mac Atom的PHP插件

    首先,需要在 ~/.atom目录下创建 .atom文件,写入如下内容: strict-ssl = false http_proxy = socks5://127.0.0.1:16888 https_p ...

  6. 离线安装部署zabbix

    一. 安装好CentOS安装过程中添加php,mariadb等所需要的依赖 二. 准备好所有所需的rpm压缩文件包在centos中解压,这里放在根目录下zabbix_rpms文件夹下 三. 安装所需r ...

  7. CentOS7安装mysql-python模块

    # sudo pip install mysql-python 此时会提示找不到mysql-config文件,我们安装一下mysql-community-devel # sudo yum instal ...

  8. 121. Best Time to Buy and Sell Stock(股票最大收益)

    Say you have an array for which the ith element is the price of a given stock on day i. If you were ...

  9. LFD,非官方的Windows二进制文件的Python扩展包

    LFD,非官方的Windows二进制文件的Python扩展包 LFD,非官方版本.32和64位.Windows.二进制文件.科学开源.Python扩展包 克里斯托夫·戈尔克(by Christoph ...

  10. MFC中利用GDI+进行双缓冲作图的有关设置

    这里只是在遇到实际问题的时候提出的一种解决方法,用以处理闪屏问题. 首先要做的是对GDI的一个设置问题: 在应用程序类中添加一个保护权限数据成员 class C...App: {... private ...