Lunch Break
InterviewTime limit2sMemory limit1024 MB
For each restaurant, add the distance from the hideout, the eating time, and the distance to the destination, then output the smallest total.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Super spy Lance Sterling is in the city and is about to leave for a mission. For convenience, a rectangular coordinate system is set up over the city, where the unit segment is one meter long. Lance is currently in a secret hideout at and needs to reach . He can move in any direction at a speed of 1 meter per second. He is very hungry, though, so he decided to grab a bite before the mission.
The city has restaurants where Lance can eat. Restaurant is at , and Lance spends exactly seconds eating there. Find the minimum time needed to reach the destination if he stops at one of the restaurants on the way.
Input
The first line contains four integers , , , and , the coordinates of the hideout and the destination ().
The second line contains one integer , the number of restaurants ().
Each of the next lines contains three integers , , and , the coordinates of restaurant and the number of seconds spent eating there (, ).
Output
Print one real number, the minimum number of seconds Lance needs to reach the destination after stopping at a restaurant. The answer is accepted if its absolute or relative error does not exceed .