hdu 4268 Alice and Bob(multiset)
来源:互联网 发布:江苏猎宝网络是真是假 编辑:程序博客网 时间:2024/05/17 01:31
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4268
题目大意:就是问你Alice的牌能覆盖Bob牌最多数量。牌不能翻转
思路:首先我们不分种类,把牌按高度排序,然后我们在依次判断牌的种类,如果是Bob的牌,我们就他牌的宽度放入multiset中,如果是Alice的牌就在multiset中找到宽度最大的那一张并删掉。
#include<cstdio>#include<iostream>#include<cstring>#include<cmath>#include<algorithm>#include<set>using namespace std;const int maxn=200005;struct Node{ int h,w,id;}node[maxn];bool cmp(Node t1,Node t2){ if(t1.h!=t2.h) return t1.h<t2.h; if(t1.w!=t2.w) return t1.w<t2.w; return t1.id<t2.id;}multiset<int > s;multiset<int >::iterator ite;int main(){ int n,i,T; scanf("%d",&T); while(T--) { scanf("%d",&n); for(i=1;i<=2*n;i++) { scanf("%d%d",&node[i].h,&node[i].w); node[i].id=(i<=n); } sort(node+1,node+2*n+1,cmp); s.clear(); int sum=0; for(i=1;i<=2*n;i++) { if(node[i].id==0) s.insert(node[i].w); else { if(s.empty()||node[i].w<*(s.begin())) continue; ite=s.upper_bound(node[i].w); //查找 ite--; sum++; s.erase(ite); //删除 } } printf("%d\n",sum); } return 0;}
0 0
- hdu 4268 Alice and Bob(multiset)
- hdu 4268 Alice and Bob(multiset)
- HDU 4268 Alice and Bob(贪心+multiset)
- HDU 4268 Alice and Bob(贪心+Multiset的应用)
- 贪心,STL,multiset(Alice and Bob,HDU 4268)
- hdu 4268 Alice and Bob(multiset|线段树)
- hdu 4268 Alice and Bob(贪心+multiset+二分)
- HDOJ 题目4268 Alice and Bob(multiset,贪心)
- 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(贪心)
- hdu4268 Alice and Bob,multiset
- HDU 4268 - Alice and Bob
- hdu 4268 Alice and Bob
- hdu 4268 Alice and Bob
- hdu - 4268 - Alice and Bob
- POJ A Knight's Journey(2488) -dfs&打印路径
- duilib创建的窗体添加边框阴影效果
- ORACLE 查看用户密码修改时间
- poj1252Euro Efficiency
- 递归与循环的区别
- hdu 4268 Alice and Bob(multiset)
- 考试题目分析
- Android 手机定位慢的解决方法
- android 自定义控件
- hdu 4893 Goffi and GCD
- Theano学习1
- spring整合memcached注意事项-poolname
- Linux下DIR,dirent,stat等结构体详解
- ubuntu12.04-64位系统上安装s2e过程