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 ...
随机推荐
- Xilinx 网站资源导
Xilinx 网站资源导读 ———版权声明———–本文作者 Ricky Suwww.fpganotes.comrickysu.fpga@gmail.com 欢迎转载,转载请保持原样及署名商业使用须得到 ...
- javascript for in 循环时,会取到Array.prototype
/** *删除数组指定下标或指定对象 */ if(!Array.prototype.remove){ Array.prototype.remove = function(obj){ for(var i ...
- Android带头像的用户注册页面
详细的图文可以到我的百度经验去查看:http://jingyan.baidu.com/article/cd4c2979eda109756e6e60de.html 首先是注册页面的布局: <?xm ...
- ###《Effective STL》--Chapter3
点击查看Evernote原文. #@author: gr #@date: 2014-09-13 #@email: forgerui@gmail.com Chapter3 关联容器 Topic 22: ...
- eNSP
L2交换机 sysvlan 200q interface Vlanif 200ip address 192.168.0.1 24dis thisq interface Ethernet 0/0/1po ...
- KMP入门(匹配)
Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M ...
- Update files embedded inside CAB file.
References: https://community.flexerasoftware.com/showthread.php?182791-Replace-a-single-file-embedd ...
- [翻译][MVC 5 + EF 6] 6:创建更复杂的数据模型
原文:Creating a More Complex Data Model for an ASP.NET MVC Application 前面的教程中,我们使用的是由三个实体组成的简单的数据模型.在本 ...
- json,serialze之格式
<?php echo 'array-json:' . "\n"; $arr = array('key1'=>'value1', 'key2' => 'value2 ...
- IOC----LightInject
开源项目 引入 LightInject.cs 默认服务 new ServiceContainer 注册跟获取获取服务 container.Register<IFoo, Foo>();con ...