
2025 · Task 3
Santa's Present Delivery
Christmas is just around the corner, and Santa is getting ready for his present-delivery mission. This year he has a whole fleet of sleighs to help him deliver presents to the good children all over town.
Each sleigh has a given capacity and fuel consumption (reindeer food, really, but we'll call it fuel to keep things simple
Santa's base is at the origin of a 2D coordinate system, and each destination is defined by its coordinates (X, Y) and a list of requested presents. Santa has an unlimited supply of presents of every type, which he will distribute across the sleighs so as to minimise fuel consumption. Presents cannot be moved from one sleigh to another during delivery.
Input
- Line 1: the number of presents N
- Line 2: N positive integers separated by spaces, where the i-th number is the weight of the i-th present (i = 1, 2, ..., N)
- Line 3: the number of sleighs M
- Line 4: M positive integers separated by spaces, where the i-th number is the capacity of the i-th sleigh (i = 1, 2, ..., M)
- Line 5: M positive integers separated by spaces, where the i-th number is the fuel consumption of the i-th sleigh (i = 1, 2, ..., M)
- Line 6: the number of destinations K
Each of the next K lines contains:
- the X, Y coordinates of the destination (decimal numbers separated by a space)
- then a vertical bar separating the coordinates from the list of presents
- the list of presents - a map of present types to requested quantities (format type:quantity, with the individual pairs separated by commas)
Presents, sleighs and destinations are indexed starting from 1.
Output
M lines representing the sleigh routes. The first line describes the route of the first sleigh, the second line that of the second sleigh, and so on.
The route of a single sleigh is described by a sequence of entries separated by spaces. Each entry consists of a destination index and the list of presents that this sleigh drops off at that destination. The destination label and the presents are separated by a vertical bar (|), and the list is described by a map (type:quantity), just as in the input.
If a sleigh is not used, print a single minus sign (-) on its line. You don't have to use all the sleighs.
Scoring
Scoring consists of two parts:
- Overall delivery efficiency
- Sleigh load balance
The total score is in the range [0, 100 000].
The total score is the sum of the points from both parts.
Overall delivery efficiency (70% of the points)
Overall efficiency measures how successfully Santa delivered all the presents while using as little fuel as possible.
For each sleigh, its delivery cost is calculated:
sleigh_cost(i) = distance_travelled(i) × fuel_consumption(i)
Total fuel consumption is defined as:
total_consumption = sum(sleigh_cost(i)) for i = 1, ..., M
The points for this part are calculated using the following function:
points = 70 000 / (1 + total_consumption / S)
where S = 40 000 (a scaling constant derived from the input data using the harmonic mean of the sleighs' fuel consumption).
Sleigh load balance (30% of the points)
This part of the scoring penalises solutions in which some sleighs are overloaded while others are not being used efficiently.
For each sleigh, its load is calculated:
sleigh_load(i) = sleigh_cargo(i) / sleigh_capacity(i)
We then take the range between the highest and lowest load across all sleighs:
range = max_load − min_load
Points for this part:
points = (1 − range)² × 30 000
Note:
- distance_travelled is calculated using the standard Euclidean formula for the distance between two points, and includes the journey from and back to the origin at the point (0, 0).
- a sleigh's cargo cannot exceed its capacity
Example
Input
Consider a simplified example with 2 presents, 3 sleighs and 4 destinations:
2 # Number of presents
2 5 # Weight of each present
3 # Number of sleighs
40 30 100 # Sleigh capacities
5 3 150 # Fuel consumption per unit of distance
4 # Number of destinations
0.50 0.20|1:1,2:2 # Destination 1: Coordinates | Requested presents (Present type:Quantity)
-0.30 0.80|1:1,2:1 # Destination 2: Coordinates | Requested presents (Present type:Quantity)
1.00 -0.40|1:2 # Destination 3: Coordinates | Requested presents (Present type:Quantity)
-0.70 -0.60|2:2 # Destination 4: Coordinates | Requested presents (Present type:Quantity)
Output
Your program could return:
4|2:2
2|1:1,2:1 1|1:1,2:2 3|1:2
-
Each line represents the route of one sleigh.
- The first sleigh travels from the origin to destination 4 and drops off two presents of type 2 there. It then returns to Santa's base.
- The second sleigh travels from the origin to destination 2 and drops off one present of type 1 and one present of type 2 there. It then goes to destination 1 and drops off one present of type 1 and two presents of type 2. Finally, it goes to destination 3 and drops off two presents of type 1. It then returns to Santa's base.
- The third sleigh is not used.
Good luck and happy coding! 🎄📸