... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Saturday, January 4, 2014

UVA-11389 :: The Bus Driver Problem

//Problem link>>http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2384

#include <bits/stdc++.h>
using namespace std ;
int main ()
{
    int n , d , r , i ,mor[105] , ev[105] ,x ,sum ;
    while (cin>>n>>d>>r  && n || d || r )
    {
        for (i=0 ; i<n ; i++) cin>>mor[i] ;
        for (i=0 ; i<n ; i++) cin>>ev[i] ;

        sort(mor , mor+n) ;
        sort(ev , ev+n) ;
        reverse (ev,ev+n) ;

         sum =0 ;
        for (i=0; i<n ; i++)
        {
            if (mor[i]+ev[i]>d) sum+= (mor[i]+ev[i]) - d ;
        }

        cout<<sum*r<<endl ;
    }

    return 0 ;
}

No comments:

Post a Comment