0
点赞
收藏
分享

微信扫一扫

codeforces 567A Lineland Mail

Python芸芸 2022-09-07 阅读 74



A. Lineland Mail



time limit per test



memory limit per test



input



output



Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the Ox

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.

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



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



Output



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.



Examples



input



4 -5 -2 2 7



output



3 12 3 9 4 7 5 12



input



2 -1 1



output



2 2 2 2



仔细审题就行!!!

#include<stdio.h>
#include<algorithm>
using namespace std;
int s[200005];
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&s[i]);
}
for(int i=0;i<n;i++)
{
if(i==0)
printf("%d %d\n",s[i+1]-s[i],s[n-1]-s[i]);
else if(i==n-1)
printf("%d %d\n",s[n-1]-s[n-2],s[n-1]-s[0]);
else
printf("%d %d\n",min(s[i]-s[i-1],s[i+1]-s[i]),max(s[i]-s[0],s[n-1]-s[i]));
}
return 0;
}




举报

相关推荐

0 条评论