Showing posts with label Volume CXIII. Show all posts
Showing posts with label Volume CXIII. Show all posts

Solution of 11389 - The Bus Driver Problem

Problem Description
source:https://uva.onlinejudge.org/external/113/11389.html

In a city there are n bus drivers. Also there are n morning bus routes and n afternoon bus routes with various lengths. Each driver is assigned one morning route and one evening route. For any driver, if his total route length for a day exceeds d, he has to be paid overtime for every hour after the first d hours at a flat r taka / hour. Your task is to assign one morning route and one evening route to each bus driver so that the total overtime amount that the authority has to pay is minimized. 

Input 

The first line of each test case has three integers n, d and r, as described above. In the second line, there are n space separated integers which are the lengths of the morning routes given in meters. Similarly the third line has n space separated integers denoting the evening route lengths. The lengths are positive integers less than or equal to 10000. The end of input is denoted by a case with three 0’s. 

image

Solution of 11364 - Parking

Problem Description
source:https://uva.onlinejudge.org/external/113/11364.html

When shopping on Long Street, Michael usually parks his car at some random location, and then walks to the stores he needs. Can you help Michael choose a place to park which minimises the distance he needs to walk on his shopping round? 
           Long Street is a straight line, where all positions are integer. You pay for parking in a specific slot, which is an integer position on Long Street. Michael does not want to pay for more than one parking though. He is very strong, and does not mind carrying all the bags around.

Input 

The first line of input gives the number of test cases, 1 ≤ t ≤ 100. There are two lines for each test case. The first gives the number of stores Michael wants to visit, 1 ≤ n ≤ 20, and the second gives their n integer positions on Long Street, 0 ≤ xi ≤ 99.

Solution of 11332 - Summing Digits

Problem Description
source:https://uva.onlinejudge.org/external/113/11332.html

For a positive integer n, let f(n) denote the sum of the digits of n when represented in base 10. It is easy to see that the sequence of numbers n, f(n), f(f(n)), f(f(f(n))), . . . eventually becomes a single digit number that repeats forever. Let this single digit be denoted g(n). 
For example, consider n = 1234567892. Then: 

    f(n) = 1+2+3+4+5+6+7+8+9+2 = 47 
    f(f(n)) = 4 + 7 = 11 
    f(f(f(n))) = 1 + 1 = 2 
    Therefore, g(1234567892) = 2.