問題一覧 > 通常問題

No.2248 max(C)-min(C)

レベル : / AI推定難易度 : 1450 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 121
作問者 : bayashiko / テスター : kumakuma 👑 AngrySadEight
お気に入りにしたユーザー ProblemId : 9301 / 自分の提出
問題文最終更新日: 2023-03-09 21:52: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
yukicoder contest 381 (順位表) の他の問題:

Problem Statement

You are given integer sequences $A=(A_1,A_2,\ldots,A_N),B=(B_1,B_2,\ldots,B_N)$, each of length $N$. Here, every element of $A,B$ is even.

There is also an integer sequence $C=(C_1,C_2,\ldots,C_N)$ of length $N$, and it is known that the value of $C_i (1\leq i \leq N)$ is one of $A_i,B_i,\frac{A_i+B_i}{2}$.

Let $\max(C)$ be the maximum value of the elements of $C$, and $\min(C)$ be the minimum value. Find the minimum possible value of $\max(C)-\min(C)$.

Input

$N$
$A_1\ A_2\ \ldots\ A_N$
$B_1\ B_2\ \ldots\ B_N$

  • $1\le N\le 2×10^5$
  • $0\le A_i,B_i\le 10^9$
  • $A_i,B_i$ are even
  • All inputs are integers

Output

Output the minimum possible value of $\max(C)-\min(C)$.

Sample

Sample 1
Input
3
6 2 12
6 10 2
Output
1

For example, when $C=(6,6,7)$, the value of $\max(C)-\min(C)$ is $1$. The value of $\max(C)-\min(C)$ can never be $0$, so the answer is $1$.

Sample 2
Input
4   
4 6 4 2
4 6 4 2
Output
4

There may be cases where there is only $1$ possibility for $C$.

Sample 3
Input
3
4 10 20
16 2 0
Output
0

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