UVa 11292 Dragon of Loowater
简单贪心
龙头的直径和人的佣金排序,价值小的人和直径小的配
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
typedef long long ll;
#define N 20005
using namespace std;
int a[N],b[N];
int main(){
int m,n;
int i,j;
while(scanf("%d%d",&n,&m)!=EOF){
if(n==&&m==)
break;
for(i=;i<=n;i++){
scanf("%d",&a[i]);
}
for(i=;i<=m;i++){
scanf("%d",&b[i]);
}
sort(a+,a++n);
sort(b+,b++m);
int ans=;
int t=;
for(i=;i<=m;i++){
if(b[i]>=a[t]){
ans=ans+b[i];
t++;
if(t-==n)
break;
}
}
if(t-<n)
printf("Loowater is doomed!\n");
else
printf("%d\n",ans);
}
}
UVa 11292 Dragon of Loowater的更多相关文章
- UVA 11292 Dragon of Loowater(简单贪心)
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- uva 11292 Dragon of Loowater (勇者斗恶龙)
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- [ACM_水题] UVA 11292 Dragon of Loowater [勇士斗恶龙 双数组排序 贪心]
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shor ...
- UVa 11292 - Dragon of Loowater(排序贪心)
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem.The shore ...
- UVA - 11292 Dragon of Loowater 贪心
贪心策略:一个直径为X的头颅,应该让雇佣费用满足大于等于X且最小的骑士来砍掉,这样才能使得花费最少. AC代码 #include <cstdio> #include <cmath&g ...
- UVa 11292 Dragon of Loowater (水题,排序)
题意:有n个条龙,在雇佣勇士去杀,每个勇士能力值为x,只能杀死头的直径y小于或等于自己能力值的龙,只能被雇佣一次,并且你要给x赏金,求最少的赏金. 析:很简单么,很明显,能力值高的杀直径大的,低的杀直 ...
- UVA它11292 - Dragon of Loowater
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- 贪心/思维题 UVA 11292 The Dragon of Loowater
题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <c ...
- cogs 1405. 中古世界的恶龙[The Drangon of Loowater,UVa 11292]
1405. 中古世界的恶龙[The Drangon of Loowater,UVa 11292] ★ 输入文件:DragonUVa.in 输出文件:DragonUVa.out 简单对比时间 ...
随机推荐
- 忘记密码流程——UUID,AES
忘记密码流程 1.进入忘记密码页面 2. 后台检验参数合法性(null,验证码,邮箱合法性) 3,生成更新密码链接,并将相关参数写入DB link=urlBase(baseurl)+updatePas ...
- jQuery:提交表单前判断表单是否被修改过
表单加载完成后执行 : //表单中包含input(text,checkbox,hidden),select,radio, $("#editWithdrawAutoApprovedConf ...
- map集合键值对存储,键值不重复,值可以重复
import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Li ...
- JDK和Tomcat环境变量,以及用MyEclipse新建Web Project测试Tomcat Server
[请尊重原创版权,如需引用,请注明来源及地址] 在此之前一直用的Eclipse挺顺手的,今天突然想换MyEclipse试试,不知安装MyEclipse的时候我选错了什么选项,反正JDK和Tomcat的 ...
- 利用C++不使用递归,循环和goto,打印1到100 的某一答案分析
实验环境是在64位linux下使用g++编译器 下面是Mark Gordon的答案 The below one works on my system, can't guarantee res ...
- java keytool证书工具使用小结
java keytool证书工具使用小结 在Security编程中,有几种典型的密码交换信息文件格式: DER-encoded certificate: .cer, .crt PEM-encod ...
- web开发工具软件使用问题记录
一.右键 - 添加Git Bash Here菜单 转自:http://blog.csdn.net/u014527912/article/details/51723735 步骤: 1.通过在“运行”中输 ...
- greendao操作数据库的使用方法
第一步:把greendao-1.3.0-beta-1,greendao-generator-1.3.1两个jar包加载到工程的lib的文件夹中,一定要右键点击Add As Library后才能使用. ...
- 根据UIColor对象,获取对应的RGBA值
- (NSArray *)getRGBWithColor:(UIColor *)color { CGFloat red = 0.0; CGFloat green = 0.0; CGFloat blue ...
- java多线程详解(8)-volatile,Atomic比较
在变成过程中我们需要保证变量的线程安全,在java中除了使用锁机制或者Threadlocal等保证线程安全,还提供了 java.util.concurrent.atomic.Atomic*(如Atom ...