TopcoderArchive
Archive
Algorithm problem

Delivery

Problem statement, definition, constraints, and public examples.

Problem Statement

You are to deliver orders to several destinations located along a straight road. The destinations will be given to you in a int[] destinations, with the ith element representing the distance in miles from the ith destination to your company's office, and the ith element of quantities represents how many orders you have for the ith destination.

Your car is at location 0 at time 0, and it goes at a constant speed of 1 mile per minute. You need to visit all destinations, spending unloadDuration at each of them filling necessary documents (this time doesn't doesn't depend on the number of units for that destination). At the end, you need to sum up all times at which orders were delivered (that is, if you deliver 2 orders to destination 0 at time 2, and 3 orders to destination 1 at time 10, the total time is 34 = 2 * 2 + 3 * 10). You are to minimize the total time and return the minimal possible value. Please note that you unload orders at each destination before spending unloadDuration minutes working with documents (see examples).

Definition

Class:
Delivery
Method:
totalTime
Parameters:
int[], int[], int
Returns:
int
Method signature:
int totalTime(int[] locations, int[] quantities, int unloadDuration)
(be sure your method is public)

Notes

  • You may pass near a destination without unloading orders if unloading them later is better.

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems