No.2248 max(C)-min(C)
タグ : / 解いたユーザー数 121
作問者 :
bayashiko
/ テスター :
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もしくは右上の雲マークをクリックしてアカウントを作成してください。