Problem list
Log in
#r00036 · anthony0506

가장 먼 두 점

Unrated 1.0 s 256 MB

평면 위에 $N$개의 점이 주어진다.

이 점들 중 서로 다른 두 점을 골랐을 때, 두 점 사이 거리의 제곱이 최대가 되는 값을 구하시오.

즉, 점 $i$의 좌표를 $(x_i, y_i)$라 할 때, 다음 값의 최댓값을 구해야 한다.

$(x_i - x_j)^2 + (y_i - y_j)^2$

Input

첫째 줄에 점의 개수 $N$이 주어진다.

둘째 줄부터 $N$개의 줄에 걸쳐 각 점의 좌표 $x_i, y_i$가 주어진다.

Output

두 점 사이 거리의 제곱의 최댓값을 출력한다.

Constraints

$2 \le N \le 200,000$ $-10^9 \le x_i, y_i \le 10^9$ 같은 좌표를 가진 점이 여러 번 주어질 수 있다. 정답은 64비트 정수 범위를 넘지 않는다.

Example 1

Input
4
0 0
0 1
1 0
1 1
Output
2
Source
anthony0506 by anthony0506
Appears in
Not part of a ladder, contest or set yet.
Accepted 3 Submissions 3 Acceptance 100% Solvers 3

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code