1.正文
#include <cstdio>
#include <iostream>
#include <algorithm>using namespace std;const int N=20000;
int d[N+5],x[N+5];int main()
{
int n,m;while(scanf("%d%d",&n,&m) == 2 && n && m){
int i,j;for(i=0;i<n;i++) scanf("%d",&d[i]);for(i=0;i<m;i++) scanf("%d",&x[i]);sort(d,d+n),sort(x,x+m);int cur=0,cost=0;for(i=0;i<m;i++){
if(x[i] >= d[cur]){
cost += x[i];if(++cur == n) break;}}if(cur < n) cout << "Loowater is doomed!" << endl;else cout << cost << endl;}return 0;
}
2. 结语
多多思考。