UVA 11292 - The Dragon of Loowater (water)
来源:互联网 发布:旋风冲锋龙卷风知乎 编辑:程序博客网 时间:2024/05/01 19:57
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2267
题目大意:n条恶龙,m个勇士,用勇士来杀恶龙。一个勇士只能杀一个恶龙。而且勇士只能杀直径不超过自己能力值的恶龙。每个勇士需要支付能力值一样的金币。问杀掉所有恶龙需要的最少金币?
题意分析:先排序,再进行筛选。
#include<stdio.h>#include<algorithm> // sort#include<iostream>#include<string.h>using namespace std;const int MAXN=20010;int A[MAXN],B[MAXN];int main(){ int n,m; int i,j; while(scanf("%d%d",&n,&m)==2 && n && m) { for(i=0;i<n;i++)scanf("%d",&A[i]); for(i=0;i<m;i++)scanf("%d",&B[i]); sort(A,A+n); sort(B,B+m); i=0; j=0; int ans=0; for(i=0;i<n;i++) { if(j>=m)break; while(j<m && A[i]>B[j])j++; if(j>=m)break; ans+=B[j]; j++; } if(i < n) printf("Loowater is doomed!\n"); else printf("%d\n",ans); } return 0;}
- UVA 11292 - The Dragon of Loowater (water)
- UVa 11292 - The Dragon of Loowater
- UVa 11292 The Dragon of Loowater
- uva 11292 The Dragon of Loowater
- UVA 11292 The Dragon of Loowater
- uva 11292The Dragon of Loowater
- Uva 11292 The Dragon of Loowater
- UVA 11292(p1)----The Dragon of Loowater
- UVa - 11292 - The Dragon of Loowater ( 贪心 )
- UVA 11292 The Dragon of Loowater
- The Dragon of Loowater,UVa 11292
- uva --11292 --Dragon of Loowater
- UVa 11292 - Dragon of Loowater
- uva - 11292 - Dragon of Loowater
- UVA 11292 - Dragon of Loowater
- uva 11292 - Dragon of Loowater
- Uva-11292-Dragon of Loowater
- UVA 11292 - Dragon of Loowater
- 2.easyui+ztree案例:在项目中引入easyui
- stm32f10x ucosii 移植要点
- Handler相关------方法,更新UI,异步,解决数据加载量等
- Java7新特性(一)Coin
- ios tableview的几个坑
- UVA 11292 - The Dragon of Loowater (water)
- nginx 四/七层负载均衡设备
- 使用DLL文件生成LIB文件实现动态链接
- OBJECT TO HEX FILE CONVERTER OH51 V2.6 COPYRIGHT KEIL ELEKTRONIK GmbH 1991 - 2001问题的解决
- css练手-android机器人
- CString截取字符串全攻略
- Mahout架构初探及KMeans算法分布式实现的研究
- Windows系统时间(FILETIME和SYSTEMTIME)
- 一份比较详细的DOS命令说明