简单贪心
龙头的直径和人的佣金排序,价值小的人和直径小的配
#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);
}
}