9
16
2015
0

[Codeforces Round #Pi] Lineland Mail


A. Lineland Mail
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the Oxaxis. No two cities are located at a single point.

Lineland residents love to send letters to each other. A person may send a letter only if the recipient lives in another city (because if they live in the same city, then it is easier to drop in).

Strange but true, the cost of sending the letter is exactly equal to the distance between the sender's city and the recipient's city.

For each city calculate two values ​​mini and maxi, where mini is the minimum cost of sending a letter from the i-th city to some other city, and maxi is the the maximum cost of sending a letter from the i-th city to some other city

Input

The first line of the input contains integer n (2 ≤ n ≤ 105) — the number of cities in Lineland. The second line contains the sequence of ndistinct integers x1, x2, ..., xn ( - 109 ≤ xi ≤ 109), where xi is the x-coordinate of the i-th city. All the xi's are distinct and follow inascending order.

Output

Print n lines, the i-th line must contain two integers mini, maxi, separated by a space, where mini is the minimum cost of sending a letter from the i-th city, and maxi is the maximum cost of sending a letter from the i-th city.

Sample test(s)
input
4
-5 -2 2 7
output
3 12
3 9
4 7
5 12
input
2
-1 1
output
2 2
2 2

题目大意:在Ox坐标轴上有n个城市,它们的坐标互不相同且已给出,从一个城市寄信到另一个城市(不能寄到它自己)的花费是它们的距离。对于所有城市,求从它出发寄一次信的最大花费和最小花费。


从一个城市寄信花费的最大值一定是它到最左边或最右边的城市的距离,最小值一定是它到相邻的城市的距离。注意特判最左边和最右边的城市就行了。

代码在此。

Category: 题解 | Tags: Codeforces 暴力 | Read Count: 304

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com