Intuitively, to have 2 and 4 both in the car is not optimal, because 4 walks faster than 3. So it's always better to just have 3 in the car whenever 2 is in the car.
So morefun is right. Just have 4,5 on the car and 2,3 on the car and compute x, y.
In general, the slowest always drives the car, and the rest are sorted from low to high and then are divided in groups of size (n-1), where n is the capacity of the car. In each group the slowest person represents the speed of the whole group. Then the problem reduces to computer x_i for each group i.
So morefun is right. Just have 4,5 on the car and 2,3 on the car and compute x, y.
In general, the slowest always drives the car, and the rest are sorted from low to high and then are divided in groups of size (n-1), where n is the capacity of the car. In each group the slowest person represents the speed of the whole group. Then the problem reduces to computer x_i for each group i.