uva 11292
不墨迹
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e6;
int a[maxn], b[maxn];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in", "r", stdin);
#endif
int n, m;
while (cin >> n >> m)
{
if (n == 0 && m == 0)
break;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < m; i++)
cin >> b[i];
sort(a, a + n);
sort(b, b + m);
int i = 0;
int j = 0;
int sum = 0;
while (i < n && j < m)
{
if (a[i] <= b[j])
{
sum += b[j];
++i, ++j;
}
else
{
++j;
}
}
if (i == n)
{
cout << sum << endl;
}
else
{
cout << "Loowater is doomed!" << endl;
}
}
}
不摸着石头过河,难道要在温柔乡睡到天昏地暗。