###### 指南第一章 例题一 UVA 11292 Dragon of Loowater（贪心算法）

【思路】：先给骑士按能力排序，恶龙按头的直径排序。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int a[20005],b[20005];
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
if(n==0&&m==0)
{
break;
}
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(int j=0;j<m;j++)
{
scanf("%d",&b[j]);
}
sort(a,a+n);
sort(b,b+m);
int cnt=0,sum=0;
for(int i=0;i<m;i++)
{
if(cnt==n)
{
break;
}
if(b[i]>=a[cnt])
{
sum+=b[i];
cnt++;
}
}
if(cnt==n)
{
printf("%d\n",sum);
}
else
{
printf("Loowater is doomed!\n");
}
}
return 0;
}


#### 【贪心】【Uva11292】 勇者斗恶龙

2014-10-08 16:10:57

#### UVA 11292 - Dragon of Loowater

2015-09-06 15:02:07

#### UVa 11292 Dragon of Loowater

2013-11-25 18:40:04

#### UVA - 11292 Dragon of Loowater

2014-08-22 20:07:39

#### 【UVa】11292 - Dragon of Loowater

2016-02-28 01:43:25

#### Dragon of Loowater UVA - 11292

2017-08-06 09:17:01

#### The Dragon of Loowater,UVa 11292

2017-08-02 09:34:03

#### UVa 11292 - The Dragon of Loowater

2012-12-04 23:42:15

#### uva 11292 - Dragon of Loowater

2013-05-09 20:48:21

#### UVA 11292 Dragon of Loowater

2015-10-01 20:59:19