题意:有一条有n个头的恶龙,有m个骑士去砍掉它们的头,每个骑士可以砍直径不超过x的头,问怎样雇佣骑士,使花的钱最少

把头的直径从小到大排序,骑士的能力值也从小到大排序,再一个一个地去砍头

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std; typedef long long LL;
const int INF = (<<)-;
const int mod=;
const int maxn=; int a[maxn],b[maxn];
int n,m; int main(){
while(scanf("%d %d",&n,&m) != EOF && n && m){
memset(a,,sizeof(a));
memset(b,,sizeof(b));
for(int i=;i<=n;i++) scanf("%d",&a[i]);
for(int i=;i<=m;i++) scanf("%d",&b[i]);
sort(a+,a+n+);
sort(b+,b+m+); int ans = ;
int cnt = ;
for(int i=;i<=m;i++){
if(b[i] >= a[cnt]) ans += b[i],cnt++;
if(cnt == n+ ) break;
}
if(cnt <= n) printf("Loowater is doomed!\n");
else printf("%d\n",ans);
}
return ;
}

UVa 11292 The Dragon of Loowater 【贪心】的更多相关文章

  1. uva 11292 The Dragon of Loowater(贪心)

    题目大意:   你的王国里有一条n个头的恶龙,你希望雇一些骑士把它杀死(即砍掉所有头).村里有m个骑士可以雇佣,一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金币.如何雇佣骑士才 ...

  2. 贪心/思维题 UVA 11292 The Dragon of Loowater

    题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <c ...

  3. UVa 11292 The Dragon of Loowater 勇者斗恶龙

    你的王国里有一条n个头的恶龙,你希望雇佣一些骑士把它杀死(也就是砍掉所有的头).村里有m个骑士可以雇佣,一个能力值为 x 的骑士可以砍掉恶龙一个直径不超过 x 的头,且需要支付 x 个金币.如何雇佣骑 ...

  4. UVA 11292 - The Dragon of Loowater (water)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=sh ...

  5. UVA - 11292 Dragon of Loowater 贪心

    贪心策略:一个直径为X的头颅,应该让雇佣费用满足大于等于X且最小的骑士来砍掉,这样才能使得花费最少. AC代码 #include <cstdio> #include <cmath&g ...

  6. UVA 11292 Dragon of Loowater(简单贪心)

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  7. UVA它11292 - Dragon of Loowater

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  8. uva 11292 Dragon of Loowater (勇者斗恶龙)

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  9. cogs 1405. 中古世界的恶龙[The Drangon of Loowater,UVa 11292]

    1405. 中古世界的恶龙[The Drangon of Loowater,UVa 11292] ★   输入文件:DragonUVa.in   输出文件:DragonUVa.out   简单对比时间 ...

随机推荐

  1. otool -l 可执行文件结构

    otool -l /Users/zzf073/Desktop/FqlMerchantX /Users/zzf073/Desktop/FqlMerchantX: Mach header magic cp ...

  2. 【转】ORACLE SQL基础—DDL语言 礼记八目 2017-12-23 21:26:21

    原文地址:https://www.toutiao.com/i6502733303550837261/ SQL语言分为:DDL数据定义语言,DML数据操纵语言,DCL是数据库控制语言,TC事务控制语言 ...

  3. 【BZOJ3065】带插入区间k小值

    题意: 带插入,修改的区间k小值在线查询 原序列长度<=35000,插入个数<=35000,修改个数<=70000,0<=权值<=70000 题解: Orz vfleak ...

  4. JAVA 上传图片功能

    前后端实现上传图片功能(JAVA代码) 1.前端大概 请求头必须为AJAX请求头: 'X-Requested-With': 'XMLHttpRequest' 一般是指网页中存在的Content-Typ ...

  5. Python for Tkinter

    # tkinter常用组件- 按钮 - button(按钮组件) - RadioButton(单选框组件) - CheckButton(选择按钮组件) - Listbox(列表框组件) - 文本输入组 ...

  6. CNN卷机网络在自然语言处理问题上的应用

    首先申明本人的英语很搓,看英文非常吃力,只能用这种笨办法来方便下次阅读.有理解错误的地方,请别喷我. 什么是卷积和什么是卷积神经网络就不讲了,自行google.从在自然语言处理的应用开始(SO, HO ...

  7. ie固定table单元格宽度

    <table border="0" style="width:690px; table-layout:fixed;"> <tr> < ...

  8. 我的Android进阶之旅------&gt; Android为TextView组件中显示的文本加入背景色

    通过上一篇文章 我的Android进阶之旅------> Android在TextView中显示图片方法 (地址:http://blog.csdn.net/ouyang_peng/article ...

  9. rails 修改数据库之后注意修改controller

    rails 修改数据库之后注意修改controller 在view中进行修改之后,注意修改controller中的内容: 这样才可以进行参数的传递:

  10. Cocos2d-x3.0 从代码中获取cocostudio编辑的UI控件

    依据名字查找控件 须要包括的头文件及名字空间: #include "cocostudio/CocoStudio.h" #include "ui/CocosGUI.h&qu ...