Hile find a function $$$dist$$$ to calculate the distance from a point to an interval. For integer $$$l,r,x(l\le r)$$$, we define $$$dist(l,r,x)$$$ as follows.
You are given $$$n$$$ pairs of integers, the $$$i$$$-th of which is $$$(l_i,r_i)$$$. It is guaranteed that $$$l_i \le r_i$$$ for all $$$i$$$. For each $$$k=1,2,...,n$$$, solve the following problem.
The first line contains a single integer $$$n(1 \le n \le 2\times 10^5)$$$ — the number of pairs.
Then $$$n$$$ lines follow, each line contains two integers $$$l_i,r_i(-10^9\le l_i\le r_i\le 10^9)$$$ — the $$$i$$$-th pair you are given.
Output $$$n$$$ lines, the $$$k$$$-th line contains a single integer, which means the minimum value of $$$\sum_{i=1}^{k}dist(l_i,r_i,x)$$$. You can choose different $$$x$$$ for different $$$k$$$.
3 1 3 6 8 6 8
0 3 3
| Name |
|---|


