Rocky Mountain
Time limit3sMemory limit1024 MB
Given a mountain range as a polyline, find the lowest site on each side of the highest peak that a straight cable can reach without crossing the range.
Problem
The Rocky Mountain Cable (RMC) company plans to run cables from the top peak of the Rocky Mountains down to lower points in the range. Cable cars will carry tourists to the highest peak.
Each cable must run in a straight line from one of the candidate sites to the highest peak, and it cannot cross any part of the mountain range. However, the cable may coincide with a slope.
To serve the most tourists, the cable should go from the highest peak down to the lowest possible site. Find the best site on the left of the highest peak and the best site on the right. If there is a tie, choose the leftmost site on the left and the rightmost site on the right.
The mountain range is given by sites . One of these sites is the unique highest peak , where and for all . The highest peak cannot be the first or the last site. The range is drawn by straight segments joining and for , where .
Input
The first line contains an integer (), the number of sites. Each of the next lines contains two integers and , the coordinates of a site. The coordinates satisfy . The input guarantees a unique highest peak and for all .
Output
On the first line, print the coordinates of the best site to the left of the highest peak. On the second line, print the coordinates of the best site to the right of the highest peak.