Rover.com interview question

How would you write this objective function?