AtCoder Regular Contest 187
D
Many Easy Optimizations
AtCoder
⌀ 2880
原题
← CE →
翻译中…

Problem Statement

翻译中…

Define the cost of a sequence $X$ as (the maximum value of $X$ minus the minimum value of $X$).

翻译中…

You are given sequences $A = (A_1, \ldots, A_N)$ and $B = (B_1, \ldots, B_N)$ of length $N$. Solve the following problem for $k = 1, 2, \ldots, N$.

翻译中…
  • Find the minimum possible cost of the sequence $C = (C_1, \ldots, C_k)$ whose $i$-th element $C_i$ is $A_i$ or $B_i$.
翻译中…

Constraints

翻译中…
  • All input numbers are integers.
  • $1 \leq N \leq 5 \times 10^5$
  • $1 \leq A_i, B_i \leq 10^9$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 \ldots A_N
B_1 \ldots B_N

翻译中…

Output

翻译中…

Print $N$ lines.

翻译中…

The $i$-th line $(1 \leq i \leq N)$ should contain the minimum possible cost of sequence $C$ for $k = i$.

翻译中…

样例

Input #1
3
8 11 10
7 6 1
Output #1
0
1
3
For $k=1$, if we choose $C = (8)$, the cost of $C$ is $0$, which is the minimum. For $k=2$, if we choose $C = (7,6)$, the cost of $C$ is $1$, which is the minimum. For $k=3$, if we choose $C = (8,11,10)$, the cost of $C$ is $3$, which is the minimum.
Input #2
10
43 35 36 58 25 7 61 4 96 3
55 29 88 15 99 49 67 57 92 49
Output #2
0
8
8
23
28
33
36
36
64
64
题目信息
题号
arc187_d
时间限制
5 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。