HDU 4268 Alice and Bob (贪心)
来源:互联网 发布:获取json的某个属性 编辑:程序博客网 时间:2024/05/16 15:50
对于 A中的 每一个扑克牌 在 x 可以覆盖的 范围内。 应该保证 被覆盖的 y尽量大。 这样 才是不浪费 y的。 并且 能够保证 后面的 A的 x更大的时候
出现 y 很小的时候 可以 覆盖 那些 x 小 并且 y 相对较小的。 这个思想很好的。
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <algorithm>#include <fstream>#include <set>#include <map>#include <queue>#include <stack>#include <list>#include <vector>#include <cmath>#include <iomanip>typedef long long LL;typedef unsigned long long LLU;const double PI=acos(-1.0);using namespace std;#define MAXN 100000+10struct card{ int x,y; friend bool operator < (card a, card b){ if(a.x != b.x) return a.x < b.x; return a.y < b.y; }};card a[MAXN],b[MAXN];int main (){ int t; scanf("%d",&t); while(t--){ int n; scanf("%d",&n); for(int i = 0; i < n; i++) scanf("%d%d",&a[i].x, &a[i].y); for(int i = 0; i < n; i++) scanf("%d%d",&b[i].x, &b[i].y); sort(a,a+n); sort(b,b+n); multiset <int> s; int p = 0; int ans = 0; for(int i = 0; i < n; i++){ while(p < n && b[p].x <= a[i].x){ s.insert(b[p].y); p++; } if(s.size() >= 1){ multiset <int> ::iterator it = s.lower_bound(a[i].y); if(it == s.end()) it--; if(it != s.begin() && (*it) > a[i].y){ it--; } if((*it) <= a[i].y){ s.erase(it); ans++; } } } printf("%d\n",ans); } return 0;}
0 0
- HDU 4268 Alice and Bob(贪心)
- HDU 4268 Alice and Bob(贪心)
- HDU 4268 Alice and Bob (贪心)
- HDU 4268 Alice and Bob(贪心)
- hdu 4268 Alice and Bob(贪心)
- hdu 4268 Alice and Bob (set+贪心)
- HDU 4268 Alice and Bob(贪心+数据结构)
- hdu 4268 Alice and Bob(贪心)
- HDU 4268 Alice and Bob (set+贪心)
- HDU 4268 Alice and Bob(贪心+multiset)
- Alice and Bob(贪心HDU 4268)
- HDU 4268-Alice and Bob-贪心
- hdu 4268 Alice and Bob矩形覆盖(贪心)
- HDU 4268 Alice and Bob(贪心+Multiset的应用)
- HDU 4268 Alice and Bob(贪心+STL)
- hdu 4268 Alice and Bob(lower_bound+贪心)
- 贪心,STL,multiset(Alice and Bob,HDU 4268)
- HDU 4268 Alice and Bob(贪心+STL)
- vector , map , set
- CI框架学习--各种demo
- 【图像格式】 TGA格式编码详解
- Javascript构造函数简析
- C++中名字隐藏是什么?
- HDU 4268 Alice and Bob (贪心)
- Spring框架学习
- android基础笔记:notification通知(android3.0以上版本适用)
- JVM简介
- nginx
- 系统开发中寻找免费且好用的甘特图控件
- IP-route管理路由
- codeforces 之 Another Problem on Strings
- 容斥原理模板(续)