BNU Concentric Rings
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
#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的更多相关文章
- 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 ...
- RFID 基础/分类/编码/调制/传输
不同频段的RFID产品会有不同的特性,本文详细介绍了无源的感应器在不同工作频率产品的特性以及主要的应用. 目前定义RFID产品的工作频率有低频.高频和甚高频的频率范围内的符合不同标准的不同的产品,而且 ...
- 分享我收集的引擎、图形学、WebGL方面的电子资料
本文分享我这一年以来收集的我认为比较经典的电子资料,希望能对大家有所帮助! 本文会不断更新! 目录 WebGL Insights OpenGL Insights Game Programming Pa ...
- G - Bullseye
Description A simple dartboard consists of a flat, circular piece of cork with concentric rings draw ...
- 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 ...
- TJU Problem 2101 Bullseye
注意代码中: result1 << " to " << result2 << ", PLAYER 1 WINS."<& ...
- Lua Rings库介绍
Rings需求 如果有一段lua脚本代码, 本来来源不可靠, 可能有安全性问题, 或者不像让这份代码污染了正在执行的lua环境, 则需要lua rings工具出厂了. 其在主lua环境中,即在宿主脚本 ...
- BNU 2418 Ultra-QuickSort (线段树求逆序对)
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=2418 解题报告:就是给你n个数,然后让你求这个数列的逆序对是多少?题目中n的范围是n & ...
- BNU OJ 33691 / LA 4817 Calculator JAVA大数
留着当个模板用,在BNU上AC,在LA上RE……可能是java的提交方式不同??? 数和运算符各开一个栈. 表达式从左到右扫一遍,将数存成大数,遇到数压在 数的栈,运算符压在 运算符的栈,每当遇到右括 ...
随机推荐
- iOS Sprite Kit教程之滚动场景
iOS Sprite Kit教程之滚动场景 滚动场景 在很多的游戏中,场景都不是静止的,而是滚动的,如在植物大战僵尸的游戏中,它的场景如图2.26所示. 图2.26 植物大战僵尸 在图2.26中,用 ...
- gpfs 内核错误
centos7.3安装旧的GPFS引发内核错误 没有关闭之前是可以查看到smap cat /proc/cpuinfo | grep smap 系统层关闭,也可以正常使用gpfs grubby --up ...
- DHTML和HTML有什么区别?有什么不同
DHTML和HTML有什么区别?有什么不同 首先Dynamic HTML是一种制作网页的方式,而不是一种网络技术(就像JavaScript和ActiveX):它也不是一个标记.一个插件或者是一个浏览器 ...
- 【十月のA Letter to 后辈菌】
文化课没什么好说的,那就不说了吧(^▽^) 以下送给下两级的学弟学妹们: 马上就要NOIP了,现在自己从戏中人变成了看戏人.不管高一还是高二,我感觉只要能走到这一步就很了不起了,不管结果如何,比赛过程 ...
- PHP 5.5以上 使用 CURL 上传文件
PHP 5.5以上 使用 CURL 上传文件的代码: curl_setopt(ch, CURLOPT_POSTFIELDS, [ 'file' => new CURLFile(realpath( ...
- 方程式0day图形化利用工具
最近方程式的漏洞着实活了一把,分析了下githup上面的文件目录,找到了利用文件,主要是针对windows主机的SMB.RDP协议进行攻击,因为我主要根据他们提供的payload的程序,利用这两个模块 ...
- 【BZOJ】4318: OSU!【期望DP】
4318: OSU! Time Limit: 2 Sec Memory Limit: 128 MBSubmit: 1473 Solved: 1174[Submit][Status][Discuss ...
- PAT甲级1123. Is It a Complete AVL Tree
PAT甲级1123. Is It a Complete AVL Tree 题意: 在AVL树中,任何节点的两个子树的高度最多有一个;如果在任何时候它们不同于一个,则重新平衡来恢复此属性.图1-4说明了 ...
- 最小生成树-普利姆算法lazy实现
算法描述 lazy普利姆算法的步骤: 1.从源点s出发,遍历它的邻接表s.Adj,将所有邻接的边(crossing edges)加入优先队列Q: 2.从Q出队最轻边,将此边加入MST. 3.考察此边的 ...
- Android性能优化之渲染
Google近期在Udacity上发布了Android性能优化的在线课程,目前有三个篇章,分别从渲染,运算与内存,电量三个方面介绍了如何去优化性能,这些课程是Google之前在Youtube上发布的A ...