http://www.bnuoj.com/bnuoj/problem_show.php?pid=16030

Concentric Rings


 

There are several different concentric rings on the ground. Some of them may overlap. In Figure 1, there are 3 rings: blue, green and red. The red one is just above the green one. The problem is to remove minimum number of rings so that no two of the remaining overlap.



Figure 1

Input

The input consists of multiple test cases. Each test case starts with a positive integer N (<=10000) which represents the number of rings. The next N lines each line contains two positive integers which represents the inner radius and outer radius respectively.

Output

For each test case, output the minimum number of rings to remove.

Sample Input:

3
1 2
3 6
4 5

Sample Output:

1

Source


这题和杭电上有个看电视的那个一样,简单贪心题,这个题首先输入有n个环,接下来每行都是环的内半径和外半径,然后求满足不能有重叠所需要删除几个环。
AC代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> using namespace std; struct Node
{
int inner,outer;
}a[10010]; bool cmp(Node a, Node b)
{
return a.outer < b.outer;
} int main()
{
int n,i,j,sum;
while(scanf("%d",&n)!=EOF)
{
sum = 0;
for(i = 0; i < n; i++)
{
scanf("%d%d",&a[i].inner,&a[i].outer);
}
sort(a,a+n,cmp);
j = 0;
for(i = 1; i < n; i++)
{
if(a[i].inner < a[j].outer)
{
sum++;
a[i].inner = a[i].outer = 0;
}
else
{
j = i;
}
}
printf("%d\n",sum);
} return 0;
}

BNU Concentric Rings的更多相关文章

  1. A trip through the Graphics Pipeline 2011_12 Tessellation

    Welcome back! This time, we’ll look into what is perhaps the “poster boy” feature introduced with th ...

  2. RFID 基础/分类/编码/调制/传输

    不同频段的RFID产品会有不同的特性,本文详细介绍了无源的感应器在不同工作频率产品的特性以及主要的应用. 目前定义RFID产品的工作频率有低频.高频和甚高频的频率范围内的符合不同标准的不同的产品,而且 ...

  3. 分享我收集的引擎、图形学、WebGL方面的电子资料

    本文分享我这一年以来收集的我认为比较经典的电子资料,希望能对大家有所帮助! 本文会不断更新! 目录 WebGL Insights OpenGL Insights Game Programming Pa ...

  4. G - Bullseye

    Description A simple dartboard consists of a flat, circular piece of cork with concentric rings draw ...

  5. Metaphor of topological basis and open set

    The definition of topological basis for a space $X$ requires that each point $x$ in $X$ is contained ...

  6. TJU Problem 2101 Bullseye

    注意代码中: result1 << " to " << result2 << ", PLAYER 1 WINS."<& ...

  7. Lua Rings库介绍

    Rings需求 如果有一段lua脚本代码, 本来来源不可靠, 可能有安全性问题, 或者不像让这份代码污染了正在执行的lua环境, 则需要lua rings工具出厂了. 其在主lua环境中,即在宿主脚本 ...

  8. BNU 2418 Ultra-QuickSort (线段树求逆序对)

    题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=2418 解题报告:就是给你n个数,然后让你求这个数列的逆序对是多少?题目中n的范围是n & ...

  9. BNU OJ 33691 / LA 4817 Calculator JAVA大数

    留着当个模板用,在BNU上AC,在LA上RE……可能是java的提交方式不同??? 数和运算符各开一个栈. 表达式从左到右扫一遍,将数存成大数,遇到数压在 数的栈,运算符压在 运算符的栈,每当遇到右括 ...

随机推荐

  1. 从Table 表中取出第 m 条到第 n 条的记录

    * FROM Table id FROM Table )) --从TABLE表中取出第m到n条记录 (Exists版本) * FROM TABLE AS a WHERE Not Exists ( * ...

  2. bzoj 4627: [BeiJing2016]回转寿司 -- 权值线段树

    4627: [BeiJing2016]回转寿司 Time Limit: 10 Sec  Memory Limit: 256 MB Description 酷爱日料的小Z经常光顾学校东门外的回转寿司店. ...

  3. hdoj 5122 K.Bro Sorting 贪心

    K.Bro Sorting Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Tot ...

  4. Vanish 详解

    1.varnish 概述:     varnish是一款高性能且开源的方向代理服务器和HTTP加速器,它的开发者poul-Henning kamp FreeBSD 核心的开发人员之一.varnish采 ...

  5. js的栈与堆

    JavaScript中基本数据类型和引用数据类型的区别  这是我引用别人的  觉得很好   1.基本数据类型和引用数据类型 ECMAScript包括两个不同类型的值:基本数据类型和引用数据类型. 基本 ...

  6. QT 开发资料

    http://pan.baidu.com/s/1bntYkpx 密码: fgsa

  7. 通过ExchangeService 发送邮件

    ExchangeService service = new ExchangeService(); service.Url = new Uri("https://***(host)/ews/e ...

  8. 深入理解 Java中的 流 (Stream)

    首先,流是什么? 流是个抽象的概念.是对输入输出设备的抽象,Java程序中,对于数据的输入/输出操作都是以"流"的方式进行.设备能够是文件,网络,内存等. 流具有方向性,至于是输入 ...

  9. C#托管堆对象实例包含什么

    每个托管堆上的对象实例除了包含本身的值外,还包括:○ Type Object Ponter: 指向Type对象实例.如果是同类型的对象实例,就指向同一个Type对象实例.○ Sync Block In ...

  10. 怎样防止ddos攻击

    所有的主机平台都有抵御DoS的设置,总结一下,基本的有几种: 关闭不必要的服务 限制同时打开的Syn半连接数目 缩短Syn半连接的time out 时间 及时更新系统补丁 网络设置 网络设备可以从防火 ...