Uva-11292-Dragon of Loowater
来源:互联网 发布:新手开淘宝店装修 编辑:程序博客网 时间:2024/04/30 02:55
比较典型的贪心题, 尽量找到能力值最小的骑士去杀死恶龙。
代码:
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#define MAX 20001using namespace std;int n,m,a[MAX],b[MAX];int main(){ while(scanf("%d%d",&n,&m)&&(n||m)) {for(int i=0;i<n;i++) scanf("%d",&a[i]);for(int i=0;i<m;i++) scanf("%d",&b[i]);sort(a,a+n);sort(b,b+m);int ans=0,cou=0,i;for(i=0;i<n;i++){ while(cou<m&&b[cou]<a[i])cou++; if(cou<m)ans+=b[cou++]; elsebreak;}if(i==n) printf("%d\n",ans);else printf("Loowater is doomed!\n"); } return 0;}
- 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
- 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
- UVA 11292 Dragon of Loowater
- uva 11292 Dragon of Loowater
- UVA - 11292 Dragon of Loowater
- UVa 11292 Dragon of Loowater
- 鼠标自动点击工具
- Ubuntu解压缩zip,tar,tar.gz,tar.bz2
- java Map java.util.ConcurrentModificationException
- php5与mysql5 web 开发技术详解-17 php优化技巧
- 第二次上机作业
- Uva-11292-Dragon of Loowater
- ipad已有2周未备份。ipad插入电源、被锁定且接入Wi-Fi时会进行备份
- 在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。
- 关于json数据
- (从浅入深)10个经典.NET习题
- 《编程回忆录》之 Unity3D 视频教程
- 第二次上机指导
- 一步一步学Yii开发(二)
- Qt内存管理之parent指针