hdu 4268
来源:互联网 发布:java 获取pom 版本号 编辑:程序博客网 时间:2024/06/05 12:44
题目链接
先按h从小到大排序,查找离w最近的值,删除他
#include <cstdio>#include <cstring>#include <set>#include <algorithm>using namespace std;#define N 100010multiset<int> myset;multiset<int>::iterator it;int n,m;struct node{ int h,w; bool operator <(const node &b) const { return h<b.h; }}a[N],b[N];int main(){ int i,j,cas,ans; scanf("%d",&cas); while(cas--) { myset.clear(); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d",&a[i].h,&a[i].w); } for(i=0;i<n;i++) { scanf("%d%d",&b[i].h,&b[i].w); } sort(a,a+n); sort(b,b+n); i=0;j=0;ans=0; while(i<n) { while(j<n&&a[i].h>=b[j].h) { myset.insert(b[j].w); j++; } it=myset.upper_bound(a[i].w); if(!myset.empty()) { if(it!=myset.begin()) it--; if(*it<=a[i].w) { ans++; myset.erase(it); } } i++; } printf("%d\n",ans); } return 0;}
- hdu 4268
- HDU 4268
- hdu 4268
- hdu 4268
- HDU 4268
- hdu 4268 贪心
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- mp4 文件数据分析
- 谁在用Hadoop
- 通过ApplicationContextAware加载Spring上下文环境
- 变形记
- #小练习 pickle模块 _ 一起存储python对象
- hdu 4268
- Linux内核RCU机制的实现 .
- 练习four.one.Etwo
- 分布式系统与网络分区
- 初学 Java Web 开发,请远离各种框架,从 Servlet 开发
- RCU锁在linux内核的演变
- android编译问题
- C语言知识点学习之if语句变量比较顺序
- UVA 11258 String Partition(dp)