Problems > Most Points on a Line

Most Points on a Line

Difficulty: 1800 6000 ms 128 MB

geometry

Print the maximum number of the given points that lie on a single straight line.

Input: the first line has N; the next N lines have distinct points x y.

Output: the largest collinear subset size.

Constraints:

  • 1 ≤ N ≤ 3000
  • |coordinates| ≤ 104

Sample Tests

Input 1
5
0 0
1 1
2 2
1 0
0 1
Output 1
3
Input 2
1
5 5
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.