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. 复杂密码生成工具apg

    复杂密码生成工具apg   密码是身份认证的重要方式.由于密码爆破方式的存在,弱密码非常不安全.为了构建复杂密码,Kali Linux预置了一个复杂密码生成工具apg.该工具可以提供可读密码和随机字符 ...

  2. Codeforces.739E.Gosha is hunting(DP 带权二分)

    题目链接 \(Description\) 有\(n\)只精灵,两种精灵球(高级和低级),每种球能捕捉到第\(i\)只精灵的概率已知.求用\(A\)个低级球和\(B\)个高级球能捕捉到精灵数的最大期望. ...

  3. [BZOJ2683]简单题/[BZOJ1176][BalkanOI2007]Mokia

    [BZOJ2683]简单题 题目大意: 一个\(n\times n(n\le5\times10^5)\)的矩阵,初始时每个格子里的数全为\(0\).\(m(m\le2\times10^5)\)次操作, ...

  4. hdu 4557 暴力

    题意: 作为2013年699万应届毕业生中的一员,由于宏观经济的不景气,小明在毕业当天就华丽丽地失业了! 经历了千难万苦的求职过程,小明特别能理解毕业生的就业之难,所以,他现在准备创建一家专门针对IT ...

  5. 开源中国上抓取的content-type

    开源中国上抓取的content-type类型,来源:http://www.cnblogs.com/smallyard/p/5632608.html { ".*": "ap ...

  6. BZOJ3522&4543 [POI2014]Hotel加强版 长链剖分

    上上周见fc爷用长链剖分秒题 于是偷偷学一学 3522的数据范围很小 可以暴力枚举每个点作为根节点来dp 复杂度$O(n^2)$ 考虑令$f[x][j]$表示以$x$为根的子树内距离$x$为$j$的点 ...

  7. NOIP2018 RP++

    飞吧,不用看向地面. NOIP,RP++.

  8. 细说React(一)

    React 是近期非常热门的一个前端开发框架. 这篇文章将介绍如何使用 React 来创建用户界面,希望能够起到抛砖引玉的效果. "React,  A JAVASCRIPT LIBRARY ...

  9. spring---aop(2)---Spring AOP的JDK动态代理

    写在前面 spring 事务是springAOP 的一个实现.我们以分析spring的事务,来分析spring的AOP实现. 基本知识 如果目标方法被spring的事务声明,则执行该目标方法的对象就会 ...

  10. How to read out WhatsApp messages with Tasker and react on their content in real time

    http://technologyworkroom.blogspot.sg/2013/05/tasker-how-to-read-out-whatsapp.html Tasker can read o ...