CodeForces 567A Gerald is into Art
http://codeforces.com/problemset/problem/567/A
3 seconds
256 megabytes
standard input
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
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.
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.
4
-5 -2 2 7
3 12
3 9
4 7
5 12
2
-1 1
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的更多相关文章
- CodeForces 560B Gerald is into Art
Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 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/ ...
- 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 ...
- 【打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 ...
- 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 ...
- Gerald is into Art
Gerald is into Art Gerald bought two very rare paintings at the Sotheby's auction and he now wants t ...
- B. Gerald is into Art
B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- CodeForces 559C Gerald and Gia (格路+容斥+DP)
CodeForces 559C Gerald and Gia 大致题意:有一个 \(N\times M\) 的网格,其中有些格子是黑色的,现在需要求出从左上角到右下角不经过黑色格子的方案数(模 \(1 ...
- 【45.65%】【codeforces 560B】Gerald is into Art
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- Spring 事务中 readOnly 的解释
spring 中事务的PROPAGATION_REQUIRED,Readonly的解释 (2012-11-21 16:29:38) 转载▼ 标签: 杂谈 一. ...
- 学习Hadoop不错的系列文章
1)Hadoop学习总结 (1)HDFS简介 (2)HDFS读写过程解析 (3)Map-Reduce入门 (4)Map-Reduce的过程解析 (5)Hadoop的运行痕迹 (6)Apache Had ...
- vi编辑器基本用法介绍
vi是Linux系统中编写文件的工具 如果vi出现乱码情况,需要升级vi,命令如下: sudo apt-get install vim //升级vi vi的启动方式有两种,直接使用vi命令和在vi命 ...
- Android查询:模拟键盘鼠标事件(adb shell 实现)
1. 发送键盘事件: 命令格式1:adb shell input keyevent “value” 其中value以及对应的key code如下表所列: KeyEvent Value KEYCODE ...
- Python模块整理(三):子进程模块subprocess
文章 原始出处 http://ipseek.blog.51cto.com/1041109/807513. 本来收集整理网络上相关资料后整理: 从python2.4版本开始,可以用subprocess这 ...
- poj 1067 取石子游戏( 威佐夫博奕)
题目:http://poj.org/problem?id=1067 题意:有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的 ...
- c++ 完成端口资料
文章地址: http://blog.csdn.net/piggyxp/article/details/6922277 附件如下: word文档 PiggyIOCPServer_2008.rar Pig ...
- Java [Leetcode 70]Climbing Stairs
题目描述: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either ...
- (1)java设计模式之简单工厂模式
一:简单工厂模式的优点 --->在阎宏博士的<JAVA与模式>一书中开头是这样描述简单工厂模式的:简单工厂模式是类的创建模式,又叫做静态工厂方法(Static Fa ...
- Arc Engine 中添加气泡提示框
一.在ArcMap中的定位操作 已知若干点的经纬度坐标,要求在地图中进行定位: 1.通过Tool >Add X Y data 定位点,注意选择地理坐标系下的wgs 1984坐标系: 2.定位后的 ...