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 简单对比时间 ...
随机推荐
- table 细边框
table { border-collapse: collapse; border: none; width: 200px; } td { border: solid #000 1px; }
- VmWare为Fedora虚拟机扩展磁盘
1.根据步骤为虚拟机扩展磁盘空间. 查看步骤 2.进入Fedora系统 以下步骤为修改扇区,将扩展磁盘划分为分区 运行fdisk -l,命令执行结果的第一行显示了磁盘名称,同时可以看到当前磁盘分区情况 ...
- linux autoload service create
---恢复内容开始--- EXEC="php-fpm" stop(){ echo "Stoping $EXEC ..." ps aux | grep " ...
- GIT GUI的使用
http://blog.csdn.net/fym0512/article/details/7713006
- python install_opener用法
opener:当你获取一个URL时,你使用一个opener(OpenerDirector).正常情况下我们一直使用默认的opener,通过urlopen,但你也可以创建自定义的openers. url ...
- Windows服务一:新建Windows服务、安装、卸载服务
Windows 服务(即,以前的 NT 服务)使您能够创建在它们自己的 Windows 会话中可长时间运行的可执行应用程序.这些服务可以在计算机启动时自动启动,可以暂停和重新启动而且不显示任何用户界面 ...
- List<Object> to JSONArray一
package com.beijxing.TestMain; import java.util.ArrayList; import java.util.List; import com.beijxin ...
- sql group by datetime on day
SELECT DATEADD(dd, DATEDIFF(dd, 0, postDate), 0)FROM tableWHERE (postDate > ...
- task9暂存
<h6>第一组项目</h6> <div class="wrap"> <div class="title"> &l ...
- 第四十四章 微服务CICD(6)- gitlab + jenkins + docker + k8s
总体流程: 在开发机开发代码后提交到gitlab 之后通过webhook插件触发jenkins进行构建,jenkins将代码打成docker镜像,push到docker-registry 之后将在k8 ...