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