A quadratic Bolza-type problem in stationary spacetimes