CF567A.Lineland Mail
入门
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position x__i — a coordinate on the Ox axis. 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 min__i and max__i, where min__i is the minimum cost of sending a letter from the i-th city to some other city, and max__i is the the maximum cost of sending a letter from the i-th city to some other city
Lineland 的所有城市都位于 Ox 坐标轴上。因此,每个城市对应一个位置 xi —— 即 Ox 轴上的一个坐标。任意两个城市均不位于同一点。
Lineland 的居民热衷于互相寄送信件。一个人仅可在收件人居住于另一座城市时寄出信件(因为若双方居住于同一座城市,则当面拜访更为便捷)。
尽管看似奇怪,但寄送信件的费用恰好等于发件人所在城市与收件人所在城市之间的距离。
对每座城市,计算两个值 mini 和 maxi,其中 mini 表示从第 i 座城市向其他某座城市寄信的最小费用,而 maxi 表示从第 i 座城市向其他某座城市寄信的最大费用。
输入格式
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 n distinct integers _x_1, _x_2, ..., x__n ( - 109 ≤ x__i ≤ 109), where x__i is the x-coordinate of the i-th city. All the x__i's are distinct and follow in ascending order.
输入的第一行包含一个整数 n(2≤n≤105)—— 表示 Lineland 中城市的数量。
第二行包含一个由 n 个互不相同的整数 x1,x2,…,xn(−109≤xi≤109)组成的序列,其中 xi 表示第 i 座城市的 x 坐标。所有 xi 互不相同,且按升序排列。
输出格式
Print n lines, the i-th line must contain two integers min__i, max__i, separated by a space, where min__i is the minimum cost of sending a letter from the i-th city, and max__i is the maximum cost of sending a letter from the i-th city.
输出 n 行,其中第 i 行必须包含两个整数 min__i 和 max__i(以空格分隔),其中 min__i 表示从第 i 个城市寄送一封信的最小花费,max__i 表示从第 i 个城市寄送一封信的最大花费。
输入输出样例
输入#1
4 -5 -2 2 7
输出#1
3 12 3 9 4 7 5 12
输入#2
2 -1 1
输出#2
2 2 2 2
输入解题思路,AI测评打分。不知道怎么写?