uva 11292

Posted corx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
        }
    }
} 

以上是关于uva 11292的主要内容,如果未能解决你的问题,请参考以下文章

uva 11292

UVa 11292 Dragon of Loowater (水题,排序)

Uva11292 Dragon of Loowater

UVA 11292 Dragon of Loowater

UVA 11292 Dragon of Loowater(简单贪心)

uva 11292 Dragon of Loowater