An Optimal 1D Vehicular Accident Warning Algorithm for Realistic Scenarios