UVA LA 7146 2014上海亚洲赛(贪心)
来源:互联网 发布:windows主进程rundll32 编辑:程序博客网 时间:2024/05/16 08:52
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=648&problem=5158&mosmsg=Submission+received+with+ID+1708713
/**UVA LA 7146 2014上海亚洲赛(贪心)题目大意:给定敌我双方士兵的数量和每个士兵的攻击力和防守力,如果两个士兵对战,一方的攻击力大于等于另一方的防守力,那么成功杀死,可能同归于尽 问在我方可以全部杀死地方士兵的情况下,问我方能剩下的士兵最多是多少解题思路:这题去年在现场没有写出来== 首先要保证的是地方所有人都要被杀死,那么把我方士兵攻击力递减排序,敌方士兵防守力递减排序。枚举敌方的 士兵,将我方所有攻击力大于其防守力的士兵入multiset,然后在其中选择第一个防守力大于当前敌方士兵攻击力的我方士兵,若没有满足的,删除 我方防守力最低的士兵*/#include <string.h>#include <stdio.h>#include <algorithm>#include <iostream>#include <set>using namespace std;typedef long long LL;const int maxn=100005;int m,n;struct note{ int x,y; bool operator < (const note &other)const { return x>other.x; }}a[maxn],b[maxn];int main(){ int T,tt=0; scanf("%d",&T); while(T--) { scanf("%d%d",&n,&m); for(int i=0;i<n;i++) { scanf("%d%d",&a[i].x,&a[i].y); } for(int j=0;j<m;j++) { scanf("%d%d",&b[j].y,&b[j].x); } sort(a,a+n); sort(b,b+m); multiset <int> st; int p=0,ans=n; for(int i=0;i<m;i++) { while(b[i].x<=a[p].x&&p<n) { st.insert(a[p++].y); } if(st.empty()) { ans=-1; break; } multiset<int>::iterator it=st.upper_bound(b[i].y); if(it==st.end()) { st.erase(st.begin()); ans--; } else st.erase(it); } printf("Case #%d: %d\n",++tt,ans); } return 0;}/**23 25 77 31 24 42 22 13 41 105 6*/
0 0
- UVA LA 7146 2014上海亚洲赛(贪心)
- 2014亚洲区域赛现场赛上海站(SET+贪心)
- UVa Live 7147 贪心(2014 上海区域赛)
- 2014ACM亚洲区域赛上海站总结
- 2014ACM/ICPC亚洲赛上海赛区总结
- LA 3602 (贪心,模拟)
- 2014年亚洲区域赛牡丹江站k题(贪心算法)
- 树状数组 LA 4329 亚洲赛北京赛区题
- 5477 A Sweet Journey (贪心_上海网络赛)
- LA 4636 Cubist Artwork(贪心)
- 杭电4011 亚洲区域赛上海赛区网络热身赛
- 2015亚洲网络赛上海站1010A Sweet Journey
- UVA 1422 (LA 4254)- Processor
- uva La 4255 Guess (拓扑排列)
- UVA 12097 Pie LA 3635 (二分)
- HDU-5583-Kingdom of Black and White(2015ACM/ICPC亚洲区上海站-重现赛)
- HDU 5572 An Easy Physics Problem(计算几何)——2015ACM/ICPC亚洲区上海站-重现赛
- ZOJ3829 ACM-ICPC 2014 亚洲区域赛牡丹江赛区现场赛K题 Known Notation 贪心
- delphi 使用superobject实现jsonrpc的http远程调用
- 日经社説 20150609 中東に欠かせぬトルコの役割
- Android实战简易教程-第十二枪(ViewFlipper实现幻灯效果)
- 系统架构推荐专题文章及书籍-会持续更新
- ubuntu Linux software install unable to locate package xxx
- UVA LA 7146 2014上海亚洲赛(贪心)
- java ArrayList<String> 与 string数组的相互转换
- 03寻找最小的k个数
- 在ViewPager中使用Fragment嵌套问题
- web中的Parameter和Attribute区别
- SystemVerilog学习心得【持续更新】
- 网络请求返回3840,回车问题
- 解决Incorrect string value错误
- 11款最棒的Linux数据恢复工具