#C7567. Minimum Trips Problem
Minimum Trips Problem
Minimum Trips Problem
You are given n facilities, each with a storage capacity and a coordinate. Your task is to transport m units of food from the first facility to the last facility. In each trip, you can transport at most f
units of food. However, if the total food stored in all facilities is less than m, then it is impossible to complete the transport.
The number of trips required is given by the ceiling of the fraction \(\frac{m}{f}\), i.e. \(\lceil m/f \rceil\). Determine the minimum number of trips needed, or output -1
if the task is impossible.
inputFormat
The input is read from stdin in the following format:
n m f capacities (n space-separated integers) coordinates (n space-separated integers)
Where:
n
is the number of facilities.m
is the total number of food units to transport.f
is the maximum food units that can be transported in one trip.capacities
is a list ofn
integers representing the capacity of each facility.coordinates
is a list ofn
integers representing the location of each facility (not used in calculations).
outputFormat
Output a single integer to stdout: the minimum number of trips required to transport m units of food, or -1
if it is impossible.
5 100 10
15 20 25 10 30
1 2 3 4 5
10
</p>