【題解】UVA 12210 A Match Making Problem

【題目敘述】https://vjudge.net/problem/UVA-12210
【解題想法】Greedy

#include <iostream>
using namespace std;

int Case, n, m, a, mn;

int main() {
    while (cin >> n >> m){
        if (n == 0 && m == 0) break;
        mn = 100;
        for (int i = 0; i < n; i++){
            cin >> a;
            mn = min(mn, a);
        }
        for (int i = 0; i < m; i++){
            cin >> a;
        }
        Case++;
        cout << "Case " << Case << ": ";
        if (n <= m) cout << 0 << "\n";
        else cout << n-m << " " << mn << "\n";
    }
}
分享本文 Share with friends