問題一覧 > 通常問題

No.909 Placement of Tapis

レベル : / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 267
作問者 : ei1333333 / テスター : たぴちゃん
お気に入りにしたユーザー ProblemId : 2988 / 自分の提出
問題文最終更新日: 2019-10-18 16:23:30
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 228 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。