問題一覧 > 通常問題

No.2436 Min Diff Distance

レベル : / AI推定難易度 : 1750 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 28
作問者 : cho435 / テスター : ebi_fly shobonvip noya2 👑 potato167
お気に入りにしたユーザー ProblemId : 10009 / 自分の提出
問題文最終更新日: 2023-08-15 00:32:10
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
traP 作問ハッカソンコンテスト 001 (順位表) の他の問題:

Problem Statement

There are $N$ points on a two-dimensional plane. The coordinates of the $i$-th point are $(X_i, Y_i)$.

For $1 \leq i \leq N$, let $P_i$ be the absolute value of the difference between the maximum and the minimum of the Manhattan distances between the $i$-th point and the other points.

Find the minimum value of $P_i$, that is, $ \min(P_1,P_2,\dots,P_N) $.

Here, the Manhattan distance between the $i$-th point and the $j$-th point is $ |X_i - X_j| + |Y_i - Y_j| $.

Constraints

  • $ 2 \leq N \leq 2 \times 10^5 $
  • $ 1 \leq X_i, Y_i \leq N $
  • $ (X_i, Y_i) \neq (X_j, Y_j)\ (i \neq j) $
  • All inputs are integers.

Input

$N$
$X_1\ Y_1$
$X_2\ Y_2$
$\vdots$
$X_N\ Y_N$

Output

Output the minimum value of $P_i$.

Sample

Sample 1
Input
4
1 1
1 2
3 2
4 4
Output
1

The values of $P_i$ are $(5,4,1,3)$, so output the minimum, $1$.

Sample 2
Input
3
1 1
2 2
3 3
Output
0

Sample 3
Input
12
1 1
5 7
5 4
9 9
10 5
2 11
6 1
9 2
1 9
4 11
11 12
9 5
Output
8

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。