标签:for water amp namespace cout pac main end algorithm
不墨迹
#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;
}
}
}
标签:for water amp namespace cout pac main end algorithm
原文地址:https://www.cnblogs.com/corx/p/13195586.html