博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4268 multiset
阅读量:4609 次
发布时间:2019-06-09

本文共 1320 字,大约阅读时间需要 4 分钟。

http://acm.hust.edu.cn/vjudge/contest/123100#problem/B

 

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
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 0x3f3f3f3fint n,m;struct node{ int h,w;}a[200005],b[200005];bool cmp(node x,node y){ return x.h < y.h;}multiset
mt;multiset
::iterator it;int main(){ int i,j; int t; sf("%d",&t); while(t--) { sf("%d",&n); for(i=1;i<=n;i++) { sf("%d%d",&a[i].h,&a[i].w); } for(i=1;i<=n;i++) { sf("%d%d",&b[i].h,&b[i].w); } sort(a+1,a+n+1,cmp); sort(b+1,b+n+1,cmp); mt.clear(); int cnt=0; for(i=1,j=1;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 0;}

 

转载于:https://www.cnblogs.com/qlky/p/5693459.html

你可能感兴趣的文章
Python2 unichr() 函数
查看>>
Python 字典 copy()方法
查看>>
Minimum Path Sum
查看>>
Remove Duplicates from Sorted Array II
查看>>
常量指针和指针常量巧妙记忆方法[转]
查看>>
python-haproxy作业讲解视频总结
查看>>
mui搜索框 搜索点击事件
查看>>
select2 下拉搜索控件
查看>>
WebAPI常见的鉴权方法,及其适用范围
查看>>
08. 删除重复&海量数据
查看>>
重新想象 Windows 8 Store Apps (71) - 其它: C# 调用 C++
查看>>
发布mvc遇到的HTTP错误 403.14-Forbidden解决办法
查看>>
记录一些好用的工具
查看>>
超链接样式设置(去下划线)(转)
查看>>
2016012003+陈琦+散列函数的应用及其安全性
查看>>
Android 状态栏通知Notification、NotificationManager详解
查看>>
UIApplicationDelegate协议
查看>>
Jmeter测试dubbo接口填坑
查看>>
[zz]GDB调试精粹及使用实例
查看>>
数据库的创建和删除
查看>>