The Bus Driver problem

Source: Internet
Author: User

Topic Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&itemid=8&page=show_problem& problem=2384

Main topic:

n drivers, set each driver in the morning afternoon each have a driving route, is given N the morning driving route length and n the afternoon driving route length, the specified length of work is d hours, if the driver work longer than d hours, then the time exceeded the R card per hour (Bangladesh currency unit) calculation of overtime costs, Q: What is the minimum amount of overtime paid by the boss after the route is assigned?

Topic Analysis:

To make the minimum amount of overtime necessary to keep each driver working as close to D as possible, the route only requires a long driving route and a short driving route. Find the minimum overtime time, and then multiply the price of the time-out.

Source:

1#include <iostream>2#include <algorithm>3 using namespacestd;4 Const intm= -;5 intMain ()6 {7     intN,d,r,i,j,min,count,a[m],b[m];8      while(cin>>n>>d>>r&&n&&d&&R)9     {  Tenmin=0; OneCount=0; A          for(i=0; i<n;i++) -cin>>a[i];//enter the given morning route length -          for(j=0; j<n;j++)  thecin>>b[j];//enter the given afternoon route length -Sort (a,a+n);//Sort -Sort (b,b+n);//Sort -          for(i=0, j=n-1; i<n,j>=0; i++,j--) +             if(a[i]+b[j]>d) -count+=a[i]+b[j]-d;//Calculate overtime Time +Min=r*count;//Calculate minimum overtime costs Acout<<min<<Endl; at     } -     return 0; -}

The Bus Driver problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.