UVA - 11389 The Bus Driver Problem

题意:有n个司机,n个下午路线n夜间路线,给司机安排一个下午路线和夜间路线,如果工作时间超过d,就要按每小时r的加班费,求最少的加班费

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 120;

int arr[MAXN],brr[MAXN];
int n,d,r;

int main(){
    while (scanf("%d%d%d",&n,&d,&r) != EOF && (n || d || r)){
        for (int i = 0; i < n; i++)
            scanf("%d",&arr[i]);
        for (int j = 0; j < n; j++)
            scanf("%d",&brr[j]);
        sort(arr,arr+n);
        sort(brr,brr+n);
        reverse(arr,arr+n);
        int sum = 0;
        for (int i = 0; i < n; i++)
            if (arr[i]+brr[i] > d)
                sum += arr[i]+brr[i] - d;
        printf("%d\n",sum*r);
    }   
    return 0;
}



你可能感兴趣的:(UVA - 11389 The Bus Driver Problem)