Two Points with the Greatest Slope
Time limit2sMemory limit128 MB
Given N points with distinct x and y coordinates, find the pair whose line has the largest absolute slope, breaking ties by smallest indices.
- Level
Hard8 of 10
- Topics
- Divide and conquer, Geometry, Sorting, Math
- Solved
- No attempts yet
Problem
You are given distinct points on a plane. All x-coordinates are distinct, and all y-coordinates are distinct.
For two points and , the absolute value of the slope of the line passing through them is
Write a program that finds the two point numbers whose absolute slope is as large as possible.
Input
The first line contains the number of points .
Each of the next lines contains the x-coordinate and y-coordinate of one point, separated by a space. Every coordinate is an integer with absolute value at most 30,000. The points are numbered from 1 to in input order.
Output
Print the numbers and of the two points with the greatest absolute slope, separated by a space. Print them so that .
If more than one pair satisfies the condition, print the pair with the smallest . If there is still more than one such pair, print the one with the smallest .