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. windows/ubuntu 文件共享之 Samba 配置

    很多时候需要在windows上和ubuntu 上共享文件,一直没怎么去找方法,得知Samba 可以实现在windows上访问linux的文件,这样一来要从windows文件放到linux中就方便了,听 ...

  2. Jquery的.post说解

    Jquery的.post说解(一) 准备工作 ·Customer类   public class Customer {     public int Unid { get; set; }     pu ...

  3. 面试题_48_to_65_Java 集合框架的面试题

    这部分也包含数据结构.算法及数组的面试问题 48) List.Set.Map 和 Queue 之间的区别(答案)List 是一个有序集合,允许元素重复.它的某些实现可以提供基于下标值的常量访问时间,但 ...

  4. CSS在不同浏览器兼容问题,margin偏移/offset溢出等

    margin在垂直取值时取最大值 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "h ...

  5. 让Eclipse和NetBeans共享同一个项目

    有的时候,我们会下载一些源代码来学习研究,但是下载下来的工程文件是eclipse的或者是NetBeans的.如果手头上没有eclipse或者没有 NetBeans,或只有其中一个怎么办?又或者,你习惯 ...

  6. HttpContext.Current.RewritePath方法重写URL

    if (!IsPostBack) { //如果请求ID为空,则重写URL为:~/index.aspx?ID=shouji.115sou.com if (Request.QueryString[&quo ...

  7. Java [Leetcode 223]Rectangle Area

    题目描述: Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is def ...

  8. windows 下FFMPEG的编译方法 附2012-9-19发布的FFMPEG编译好的SDK下载

    经过一晚上加一上午的奋斗,终于成功编译出了最新版的FFMPEG,下面是我编译的心得,因为是最新的,应该会对大家有用,编译的FFMPEG的版本是0.11.2,2012-09-19新发布的版本 平台:WI ...

  9. h.264码流解析_一个SPS的nalu及获取视频的分辨率

    00 00 00 01 67 42 00 28 E9 00  A0 0B 77 FE 00 02 00 03 C4 80  00 00 03 00 80 00 00 1A 4D 88  10 94 0 ...

  10. 一个P2P点播直播开源项目:P2PCenter

    最近跟着公司的项目走,我也研究了不少东西,尤其是在P2P方面,广泛涉猎各种开源项目,尤其是国外的开源项目,意外的发现了一个国内的项目,做的还不错,推荐一下.---------------------使 ...