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 ...
随机推荐
- Win7下简约的Gif查看器 仅1.8M
win7下面由于版权的原因把,默认打开gif的是ie浏览器,这个多么的不方便呀,我在网上淘到了这个程序,话说是从Xp中提取移植过来的.用起来很不错. 下载地址在: http://pan.baidu.c ...
- hive外部表自动读取文件夹里的数据
我们在创建表的时候可以指定external关键字创建外部表,外部表对应的文件存储在location指定的目录下,向该目录添加新文件的同时,该表也会读取到该文件(当然文件格式必须跟表定义的一致),删除外 ...
- 一步一步创建一个简单的Package(1)
创建Package之前首先我们理解需求: 数据源是一组历史货币数据包含在平面文件SampleCurrencyData.txt中,源数据中有四列. 下面是SampleCurrencyData.txt文件 ...
- spring中加入log4j
spring中加入log4j <context-param> <param-name>log4jConfigLocation</param-name> <pa ...
- asp.net 中使用JQuery Ajax 上传文件
首先创建一个网页,网页中添加如下代码. <h3>Upload File using Jquery AJAX in Asp.net</h3> <table> < ...
- 【原创】关于MVC自己新建的 action,Controller提示找不到页面的问题
一.实例: 1.比如我自己新建了一个~/view/Shop 文件夹下的IndexShop.aspx,那么在Controllers文件夹下就要对应一个ShopController.cs的Control ...
- CSS3滤镜!!!
<!DOCTYPE html> <html> <head> <style> img { width: 33%; height: auto; float: ...
- Oracle PL/SQL 事物处理 银行转账
Oracle数据库中的事务处理:添加,修改,删除时需要使用事务处理(显示事务). 1.事务的分类显示事务(添加,修改,删除)和隐式事务(除了添加,修改,删除). 2.事务的执行方式:自动提交(jdbc ...
- bzoj1015:[JSOI2008]星球大战starwar
思路:反着做用并查集维护连通块个数就好了. #include<iostream> #include<cstdio> #include<cstring> #inclu ...
- MYSQL Error 2006HY000:MySQL server has gone away的解决方案
MySQL server has gone away有几种情况. 1.应用程序(比如PHP)长时间的执行批量的MYSQL语句. 最常见的就是采集或者新旧数据转化. 解决方案: 在my.cnf文件中添加 ...