#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=20000+5;
int a[maxn];
int b[maxn];
int main()
{
int n,m;
while(scanf("%d %d",&n,&m)==2 && (n&&m))
{
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
for(int i=0; i<m; i++)
{
scanf("%d",&b[i]);
}
if(n>m)
{
printf("Loowater is doomed!\n");
continue;
}
else
{
sort(a,a+n);
sort(b,b+m);
int sum=0;
int i,j;
for(i=0,j=0;i<n;i++)
{
while(b[j]<a[i])
{
j++;
}
if(j>=m) break;
sum+=b[j++]; //用完 j++;
}
if(i>=n)
{
printf("%d\n",sum);
}
else
{
printf("Loowater is doomed!\n");
}
}
}
return 0;
}
uva 11292
最新推荐文章于 2023-04-15 19:00:26 发布