No.909 Placement of Tapis
Problem Statement
There are $N + 2$ tapis, numbered from $0$ to $N + 1$.
You will place all the tapis at integer coordinates on a number line. Multiple tapis may be placed at the same coordinate.
However, for each tapi $i(1 \leq i \leq N)$, the following conditions must be satisfied.
- The distance from tapi $i$ to tapi $0$ is at most $X_i$.
- The distance from tapi $i$ to tapi $N + 1$ is at most $Y_i$.
Tapi $0$ and tapi $N + 1$ are on bad terms. Therefore, find the maximum possible distance from tapi $0$ to tapi $N + 1$, along with an example of a placement of the tapis that achieves it.
Input
$N$ $X_1$ $X_2$ $\cdots$ $X_N$ $Y_1$ $Y_2$ $\cdots$ $Y_N$
- $1 \leq N \leq 2 \times 10^5$
- $0 \leq X_i, Y_i \leq 10^6$
- All inputs are integers.
Output
The output consists of $N + 3$ lines.
On the $1$st line, print the maximum distance from tapi $0$ to tapi $N + 1$.
On the following $N + 2$ lines, print the coordinates of the $N + 2$ tapis, one per line, in order starting from tapi $0$.
The coordinates of all tapis must be integers between $0$ and $10^{18}$, inclusive.
If there are multiple valid placements, you may print any of them.
Sample
Sample 1
Input
2 1 10 2 1
Output
3 0 1 2 3
The maximum distance from tapi $0$ to tapi $3$ is $3$.
If tapis $0$ through $3$ are placed at coordinates $0, 1, 2, 3$, respectively, then
- the distance from tapi $1$ to tapi $0$ is $1$,
- the distance from tapi $1$ to tapi $3$ is $2$,
- the distance from tapi $2$ to tapi $0$ is $2$, and
- the distance from tapi $2$ to tapi $3$ is $1$,
so all the conditions are satisfied.
Sample 2
Input
3 0 0 0 0 0 0
Output
0 3 3 3 3 3
The maximum distance from tapi $0$ to tapi $4$ is $0$.
All the tapis must be placed at the same coordinate.
Sample 3
Input
3 50 20 1 40 30 1
Output
2 2 35 15 1 0
The maximum distance from tapi $0$ to tapi $4$ is $2$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ei1333333
たぴちゃん