http://codeforces.com/problemset/problem/567/A

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 ofn distinct 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
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define N 100010
#define INF 0x3f3f3f3f
#define max(a, b)(a > b ? a : b)
#define min(a, b)(a < b ? a : b) int c[N];
int main()
{
int n, i, Min, Max;
while(~scanf("%d", &n))
{
for(i = ; i <= n ; i++)
scanf("%d", &c[i]);
printf("%d %d\n", abs(c[] - c[]), abs(c[] - c[n]));
for(i = ; i < n ; i++)
{
Min = min(abs(c[i] - c[i - ]), abs(c[i] - c[i + ]));
Max = max(abs(c[] - c[i]), abs(c[i] - c[n]));
printf("%d %d\n", Min, Max);
}
printf("%d %d\n", abs(c[n] - c[n - ]), abs(c[n] - c[]));
}
return ;
}

CodeForces 567A Gerald is into Art的更多相关文章

  1. CodeForces 560B Gerald is into Art

     Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #313 (Div. 2)B.B. Gerald is into Art

    B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/ ...

  3. Codeforces Round #313 (Div. 2) B. Gerald is into Art 水题

    B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560 ...

  4. 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)

    [CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...

  5. Codeforces Round #313 B. Gerald is into Art(简单题)

    B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  6. Gerald is into Art

    Gerald is into Art Gerald bought two very rare paintings at the Sotheby's auction and he now wants t ...

  7. B. Gerald is into Art

    B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  8. CodeForces 559C Gerald and Gia (格路+容斥+DP)

    CodeForces 559C Gerald and Gia 大致题意:有一个 \(N\times M\) 的网格,其中有些格子是黑色的,现在需要求出从左上角到右下角不经过黑色格子的方案数(模 \(1 ...

  9. 【45.65%】【codeforces 560B】Gerald is into Art

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. Word 中没有Endnote工具栏的解决方法

    环境:Windows XP + Word 2003 + EndNote 6 以下各方法可以依次试一下,需要重启Word后才能看到是否可行.1 视图 -- 工具栏 -- EndNote,是否打勾.2 w ...

  2. git终端提示符

    最近使用git bash的时候,看到默认的终端提示符不爽,主要是太长了.所以想对git终端提示符进行优化 默认git的终端提示符会是  用户名@设备名称 ,我想改成更短的来查看. 提示符是由一个环境变 ...

  3. 计算几何基础——矢量和叉积 && 叉积、线段相交判断、凸包(转载)

    转载自 http://blog.csdn.net/william001zs/article/details/6213485 矢量 如果一条线段的端点是有次序之分的话,那么这种线段就称为 有向线段,如果 ...

  4. Qt之运行一个实例进程

    简述 发布程序的时候,我们往往会遇到这种情况: 只需要用户运行一个实例进程 用户可以同时运行多个实例进程 一个实例进程的软件有很多,例如:360.酷狗- 多个实例进程的软件也很多,例如:Visual ...

  5. bzoj1934: [Shoi2007]Vote 善意的投票

    最大流..建图方式都是玄学啊.. //Dinic是O(n2m)的. #include<cstdio> #include<cstring> #include<cctype& ...

  6. 手动配置gradle

    最近从github倒入项目,运行的特别慢gradle配置有问题,解决方法: 1.C:\android\demo\hellocharts-android-master\gradle\wrapper 目录 ...

  7. DirectX截图黑屏的解决办法

    好久没有更新博客了,今天开始继续耕耘. 生活要继续 工作要继续 梦想也一定要继续! 之前写过一篇关于DirectX截屏的文章,其中有网友留言提到了截图黑屏的问题,于是这些日子研究了一下,与大家一同分享 ...

  8. 【CSS】css各种居中方法

    水平居中的text-align:center 和 margin:0 auto   这两种方法都是用来水平居中的,前者是针对父元素进行设置而后者则是对子元素.他们起作用的首要条件是子元素必须没有被flo ...

  9. javascript实现map的功能(转载)

    /* * MAP对象,实现MAP功能 * * 接口: * size() 获取MAP元素个数 * isEmpty() 判断MAP是否为空 * clear() 删除MAP所有元素 * put(key, v ...

  10. 如何打开和关闭Oracle Flashback

    1.打开flashback: 关闭数据库 SQL>shutdown immediate; 启动到mount方式 SQL>startup mount; 如果归档没有打开,打开归档[因为fla ...