AtCoder Regular Contest 129
B
Range Point Distance
AtCoder
⌀ 735
原题
← AC →
翻译中…

Problem Statement

翻译中…

For integers $l$, $r$, and $x$ ($l \leq r$), let us define $dist(l,r,x)$ as follows.

翻译中…
  • If $x<l$: $dist(l,r,x)=l-x$
  • If $l \leq x \leq r$: $dist(l,r,x)=0$
  • If $r<x$: $dist(l,r,x)=x-r$
翻译中…

You are given $N$ pairs of integers, the $i$-th of which is $(L_i,R_i)$. For each $k=1,2,\cdots,N$, solve the following problem.

翻译中…
  • Let us choose an integer $x$ freely and compute $\max(dist(L_1,R_1,x),dist(L_2,R_2,x),\cdots,dist(L_k,R_k,x))$. Find the minimum possible value of this.
翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq L_i \leq R_i \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
L_1 R_1
L_2 R_2
\vdots
L_N R_N

翻译中…

Output

翻译中…

Print the answers for $k=1,2,\cdots,N$ in this order.

翻译中…

样例

Input #1
3
1 3
2 4
5 6
Output #1
0
0
1
- For $k=1$, an optimal choice is $x=1$. - For $k=2$, an optimal choice is $x=3$. - For $k=3$, an optimal choice is $x=4$.
Input #2
10
64 96
30 78
52 61
18 28
9 34
42 86
11 49
1 79
13 59
70 95
Output #2
0
0
2
18
18
18
18
18
18
21
题目信息
题号
arc129_b
时间限制
2 s
内存限制
1024 MB

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