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 ...
随机推荐
- JAXB - Annotations, Annotations for Enums: XmlEnum, XmlEnumValue
An enum type is annotated with XmlEnum. It has an optional element value of type java.lang.Class whi ...
- ListView的item中有button和checkbox,listview的点击事件无效
ListView的item中有button和checkbox,listview的点击事件无效,解决办法: 在item布局文件中的根控件中添加属性设置: android:descendantFocusa ...
- angularjs开发总结
使用AngularJS有差不多一年时间了,前前后后也用了不少库和指令,整理了一下,分成四大类列出.有demo地址的,就直接连接到demo地址,其它的直接链到github托管库中. 图片视频类 angu ...
- HW--漂亮度2(测试通过)
总结:几个函数的使用 (1) int num=Integer.parseInt(str[0]); //将第一个字符串转成整形数,表示名字个数 (2) String string1=str[i].to ...
- 安装oracle 12c遇到问题
安装前步骤:更改用户账户控制设置:从不通知 出现 "SEVERE: [FATAL] [INS-30014] 无法检查指定的位置是否位于 CFS 上" 解决办法:重新设置hosts ...
- 第十二篇、高度自适应的textView
高度根据输入内容变化输入框,我们在很多的应用上都可以见到,如微信.QQ聊天,QQ空间评论等等,该输入框可以用xib,纯代码编写,但是个人觉得纯代码编写用起来更加方便一些. 1.使用自定义的UIView ...
- JavaScript中事件绑定的方法总结
最近收集了一些关于JavaScript绑定事件的方法,汇总了一下,不全面,但是,希望便于以后自己查看. JavaScript中绑定事件的方法主要有三种: 1 在DOM元素中直接绑定 2 JavaScr ...
- 在 Eclipse 中使用 JSHint 检查 JavaScript 代码
JSHint Home: http://www.jshint.com/ JSHint Options: http://www.jshint.com/options/ JSHint For Eclips ...
- 2.2_线性表的顺序存储结构_参考集合ArrayList
[线性表的顺序存储从结构] 指的是用一段连续的存储单元一次储存线性表的数据元素. [线性表的顺序存储的结构代码 C语言版] #define MAXSIZE 20 /*存储空间初始分配量*/ typed ...
- Microsoft Excel Sheet/表格 制作折线图
Microsoft Excel Sheet/表格 制作折线图 虽然比较简单,但是仍然需要稍微花一点功夫. 1.制作好表格数据 2.先将数据选定(不包括 横座标的 年月日或其他的刻度 的那一列) 3.插 ...