Courier Constellation: Neighbors Decide the ETA
The Courier Constellation predicts delivery time in minutes from three clues: distance
in kilometers, payload weight
in kilograms, and the vehicle type
: bike, car, or drone. Some vehicles fly, some weave through traffic, and some sit in it; to compare them fairly, times are estimated by looking at similar past jobs and averaging their outcomes.

You are asked to read a set of historical deliveries and then estimate the time for new requests using k-NN Regression. Make the two numeric features comparable by scaling them using the min-max scaling, with statistics computed from the historical data only. Represent the vehicle with a one-hot vector using the provided vocabulary and its order. Compare jobs with Euclidean distance using the combination of the two scaled numeric values together with the one-hot vehicle. Predict each time as the mean of its k nearest historical times. If a numeric column in the historical data is flat, its scaled value is 0. You may assume that all vehicles in the input appear in the given vocabulary.
The first line of the input contains a single integer v
representing how many vehicle types there are. The second line contains v
space-separated vehicle names: the vehicle vocabulary.
The next line contains two integers n k
describing how many historical rows there are and the number of neighbors to use. Each of the next n
lines contains four values - distance weight vehicle target_time
.
The next line contains a single integer q
representing how many new deliveries to estimate. Each of the next q
lines contains distance weight vehicle
for a new delivery.
The program should print q
lines. Each line should contain a single real number - the predicted delivery time for that new request.
Input | Output |
---|---|
3 | 15.666666666666666 |
3 | 9 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB