hdu 4268
set的利用;
#include<cstdio>
#include<set>
#include<algorithm>
#define maxn 100009
using namespace std; struct node
{
int w,h;
bool operator <(const node& t)const
{
if(w==t.w)return h<t.h;
return w<t.w;
}
}a[maxn],b[maxn]; multiset<int>s;
multiset<int>::iterator it;
int main()
{
int n,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
s.clear();
int sum=;
for(int i=;i<n;i++)scanf("%d%d",&a[i].w,&a[i].h);
for(int i=;i<n;i++)scanf("%d%d",&b[i].w,&b[i].h);
sort(a,a+n);
sort(b,b+n);
int j=;
for(int i=;i<n;i++)
{
while(j<n&&b[j].w<=a[i].w)
{
s.insert(b[j].h);
j++;
}
if(!s.size())continue;
it=s.upper_bound(a[i].h);
if(it!=s.begin())
{
sum++;
s.erase(--it);
}
}
printf("%d\n",sum);
}
return ;
}
hdu 4268的更多相关文章
- hdu 4268 multiset+贪心
Alice和Bob有n个长方形,有长度和宽度,一个矩形可以覆盖另一个矩形的条件的是,本身长度大于等于另一个矩形,且宽度大于等于另一个矩形,矩形不可旋转,问你Alice最多能覆盖Bob的几个矩形? /* ...
- HDU 4268 Alice and Bob set用法
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4268 贪心思想,用set实现平衡树,但是set有唯一性,所以要用 multiset AC代码: #i ...
- hdu 4268 贪心+set lower_bound用法
http://acm.hdu.edu.cn/showproblem.php?pid=4268 A想用手里的牌尽量多地覆盖掉B手中的牌.. 牌有h和w 问A手中的牌最多能覆盖B多少张牌 iterator ...
- hdu 4268 Alice and Bob
Alice and Bob Time Limit : 10000/5000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Tota ...
- Alice and Bob(贪心HDU 4268)
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- hdu 4268 Alice and Bob(multiset|段树)
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- Alice and Bob HDU - 4268
Alice and Bob's game never ends. Today, they introduce a new game. In this game, both of them have N ...
- HDU 4268 Alice and Bob 贪心STL O(nlogn)
B - Alice and Bob Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u D ...
- HDU 4268 multiset
http://acm.hust.edu.cn/vjudge/contest/123100#problem/B #include <iostream> #include <string ...
随机推荐
- 关于Eclipse插件开发-----加入首选项(preferencePages)
选择主菜单"窗口---->首选项"命令打开"首选项"窗口.此窗口是Eclipse设置项的集中营, 修改plugin.xml文件,设置首选项的扩展点: pl ...
- 关于Git补丁文件交互
之前各个章节的版本库的交互都是通过 git push和git pull命令来实现的.这个是Git最主要的交互模式,但并不是全部. 使用补丁文件是另外一种交互方式,适用于参与者众多的大型项目进行的分布式 ...
- Linux下root密码忘记的解决办法
{启动方式} ========================================================================== 一. lilo 1. 在出现 lil ...
- (ASP.net)利用Application对象制作简单聊天室
1.共四个页面,Default.aspx默认主页,Default2.aspx聊天室 default3.aspx显示用户列表,default4.aspx显示聊天内容,添加一个Global.asax全局程 ...
- hhgis驱动
function loadPathInfo 在car.js中 function loadPathInfo(carid, fnClass) { var qureydrive; if (jsonp) qu ...
- 关于修改tabbar的颜色的问题
首先,项目是在故事板中搭建的,所以遇到这个问题的时候,首先是想到在故事板中找到相关的属性,确实是有一个Selected Image,但是设置了这个图片以后,运行的效果是,点击选择后,本身的image就 ...
- iOS开发——屏幕尺寸适配
对于屏幕尺寸适配,目前先指竖屏的方式适合方式1和2. 1.控件尺寸写死的方式,偶尔会用到屏幕的宽度和高度. UILabel *holdLabel = [[UILabel alloc]initWithF ...
- 转:如何取得Spring管理的bean
原文链接:http://blog.csdn.net/a9529lty/article/details/42145545 1.servlet方式加载时,[web.xml] <servlet> ...
- 代码静态分析工具PCLint, Splint
一.PCLint REFER: 代码静态检查工具PC-Lint运用实践 二.Splint 1.在PC-Linux上安装 ①make error undefined reference toyywrap ...
- 基本上,把switch,用设计模式代替,肯定是bug和过度设计。想想,本来修改一个文件几行代码可以解决的问题,变成修改3-6个类才能实现一样的功能。不是傻是什么?
那些迷信设计模式的人,来修改一下这个方法吧.看看你最终的代码膨胀为几倍... public virtual PasswordChangeResult ChangePassword(ChangePass ...