HDU 4268 multiset
http://acm.hust.edu.cn/vjudge/contest/123100#problem/B
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define MAXN 100000 + 10
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue
#define INF 0x3f3f3f3f int n,m; struct node
{
int h,w;
}a[],b[]; bool cmp(node x,node y)
{
return x.h < y.h;
} multiset<int> mt;
multiset<int>::iterator it; int main()
{
int i,j;
int t;
sf("%d",&t);
while(t--)
{
sf("%d",&n);
for(i=;i<=n;i++)
{
sf("%d%d",&a[i].h,&a[i].w);
}
for(i=;i<=n;i++)
{
sf("%d%d",&b[i].h,&b[i].w);
}
sort(a+,a+n+,cmp);
sort(b+,b+n+,cmp); mt.clear(); int cnt=;
for(i=,j=;i<=n;i++)
{
while(j<=n && a[i].h>=b[j].h)
{
mt.insert(b[j].w);
j++;
}
if(mt.empty()) continue;
it = mt.upper_bound(a[i].w);
if(it!=mt.begin()) it--;
if((*it) <= a[i].w)
{
cnt++;
mt.erase(it);
}
}
pf("%d\n",cnt); }
return ;
}
HDU 4268 multiset的更多相关文章
- hdu 4268 multiset+贪心
Alice和Bob有n个长方形,有长度和宽度,一个矩形可以覆盖另一个矩形的条件的是,本身长度大于等于另一个矩形,且宽度大于等于另一个矩形,矩形不可旋转,问你Alice最多能覆盖Bob的几个矩形? /* ...
- hdu 4268 Alice and Bob(multiset|段树)
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu 4268 Alice and Bob(贪心+multiset)
题意:卡牌覆盖,每张卡牌有高(height)和宽(width).求alice的卡牌最多可以覆盖多少bob的卡牌 思路:贪心方法就是找h可以覆盖的条件下找w最大的去覆盖. #include<ios ...
- HDU 4268 Alice and Bob(贪心+Multiset的应用)
题意: Alice和Bob有n个长方形,有长度和宽度,一个矩形能够覆盖还有一个矩形的条件的是,本身长度大于等于还有一个矩形,且宽度大于等于还有一个矩形.矩形不可旋转.问你Alice最多能覆盖Bo ...
- 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 2275 multiset
题意:n个操作 Push 入容器 Pop弹出一个 满足<=该数的最大的数(若没有输出No Element!) 开始用set打了一遍wrong了,这里入容器的数是有重复的,所以用multiset ...
随机推荐
- loj #2508. 「AHOI / HNOI2018」游戏
#2508. 「AHOI / HNOI2018」游戏 题目描述 一次小 G 和小 H 在玩寻宝游戏,有 nnn 个房间排成一列,编号为 1,2,…,n,相邻房间之间都有 111 道门.其中一部分门上有 ...
- 使用TortoiseSVN新建及合并分支图文教程
打开trunks目录,在trunks目录下新建两个文本文件A.java,B.java: 打开A.java输入以下内容: B.java文件可以随机输入些,本例中主要用于观察后续是否变化. 两个文件编 ...
- [HAOI2011]Problem b BZOJ2301 数学
题目描述 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. 输入输出格式 输入格式: 第一行一个整数 ...
- 请求一个域名ip的缓存用处
前言 摘录自操作系统,这一段的内容很有启发,稍微加上自己的理解,写一篇博客记录一下. 缓存 缓存成功解决了速度不匹配设备之间的数据传输,并且在一般情况下,是整个系统的瓶颈:缓存的出现,有效减少了低速I ...
- @staticmethod 和@classmethod区别
python中@classmethod @staticmethod区别 Python中3种方式定义类方法, 常规方式, @classmethod修饰方式, @staticmethod修饰方式. cla ...
- 校园网络安全CTF 第一题 和 你真了解我吗?
第一题: 需要先找到相应头(REsponse header中的tips) <?php$flag = "***";if (isset($_GET['repo']))//检测变量 ...
- Windows 搭建ASP.NET Boilerplate项目开发环境
1.本机安装对应版本的.net core 2.安装vs2017或以上版本 3.从ABP官网下载模板,我下载的是前后端分离的Angular模板 4.用vs2017分别打开前后端,还原Nuget包 5.前 ...
- [转] 智能合约开发环境搭建及Hello World合约
[From] http://www.cnblogs.com/tinyxiong/p/7898599.html 如果你对于以太坊智能合约开发还没有概念(本文会假设你已经知道这些概念),建议先阅读入门篇. ...
- 基于docker+redis++urlib/request的分布式爬虫原理
一.整体思路及中心节点的配置 1.首先在虚拟机中运行一个docker,docker中运行的是一个linux系统,里面有我们所有需要的东西,linux系统,python,mysql,redis以及一些p ...
- 2.4 GO Interface
package itface type Sender interface { Send(url string) string } type Geter interface { Get(url stri ...