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 ...
随机推荐
- C#+ArcEngine 序列化和反序列化AE对象
http://www.cnblogs.com/jindin/archive/2009/07/23/1529695.html 在AE开发过程,总是要将某些对象暂时存储起来,像element,layer, ...
- Java_Web _Servlet生命周期实验
第一次加载这个servlet程序时(选择右边的servlet程序,注意servlet程序没有main函数,因此执行的是run as servlet Application ),同时执行init()方法 ...
- Web应用程序安全必须重视八大问题
摘自:http://netsecurity.51cto.com/art/201402/428709.htm 对于任何一个项目,开始阶段对于交付安全的应用来说非常关键.适当的安全要求会导致正确的安全设计 ...
- ###STL学习--关联容器
点击查看Evernote原文. #@author: gr #@date: 2014-08-23 #@email: forgerui@gmail.com STL中的关联容器. ###stl学习 |--迭 ...
- OC4_可变数组
// // main.m // OC4_可变数组 // // Created by zhangxueming on 15/6/11. // Copyright (c) 2015年 zhangxuemi ...
- javaee学习-新建servlet 直接返回html
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletExcepti ...
- 07_控制线程_join_线程插队
[join线程简述] join()方法:Thread提供的让一个线程去等待另一个线程完成.当在某个程序执行流中(如main线程)调用其它线程(如t2线程)的join方法(t2.join()),调用线程 ...
- linux下搭建nginx+php(FastCGI)+mysql运行环境
一.安装环境 1.CentOS5.5 2.php5.4 3.MySQL5.5.19 二.安装程序依赖库和开发环境 为了省事把所需要的库文件全都安装上,可以使用rpm包安装,也可以用yum命令安装, 1 ...
- C#语法需要注意的地方
笔试中遇到的一些C#语法方面的问题,由于平时很少用到,笔试的时候模棱两可,现在做一个笔记. using System; using System.Collections.Generic; using ...
- Chrome 将默认不播放非重要 Flash 内容
Chrome 45将不再自动播放Flash,可能是45以后的版本都不自动播放了,没有具体测试. 小尺寸flash不被chrome播放,需要手动点击才能播放如何解决: <p>1.同域名fla ...