1. 程式人生 > >11389 The Bus Driver Problem——思維

11389 The Bus Driver Problem——思維

排個序就行,大水題

#include <bits/stdc++.h>
using namespace std;
int n, d, r;
int a[500], b[500];
bool cmp(int x, int y) { return x > y; }
int main() {
    while (~scanf("%d%d%d", &n, &d, &r) && n + d + r) {
        for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
        for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
        sort(a+1, a+1+n);
        sort(b+1, b+1+n, cmp);
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i]+b[i]>d) {
                ans += r*(a[i]+b[i]-d);
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}