Skip to main content
  1. Posts/

codeforces #314 A. Lineland Mail

·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

给一个有序序列,问对于没一个数,和它相差最少和最多的数的位置。

 1/*************************************************************************
 2	> File Name: code/cf/#314/A.cpp
 3	> Author: 111qqz
 4	> Email: rkz2013@126.com
 5	> Created Time: 2015年08月06日 星期四 00时01分51秒
 6 ************************************************************************/
 7
 8#include<iostream>
 9#include<iomanip>
10#include<cstdio>
11#include<algorithm>
12#include<cmath>
13#include<cstring>
14#include<string>
15#include<map>
16#include<set>
17#include<queue>
18#include<vector>
19#include<stack>
20#define y0 abc111qqz
21#define y1 hust111qqz
22#define yn hez111qqz
23#define j1 cute111qqz
24#define tm crazy111qqz
25#define lr dying111qqz
26using namespace std;
27#define REP(i, n) for (int i=0;i<int(n);++i)
28typedef long long LL;
29typedef unsigned long long ULL;
30const int inf = 0x7fffffff;
31const int N=2E5+7;
32LL a[N];
33int main()
34{
35    int n;
36    cin>>n;
37    a[0]=-inf;
38    a[n+1]=inf;
39
40    for ( int i  = 1 ; i <= n ; i ++ )
41    {
42	cin>>a[i];
43    }
44    int mx = -1;
45    int mi = inf;
46    cout<<a[2]-a[1]<<" "<<a[n]-a[1]<<endl;
47    for ( int i = 2 ; i <= n-1 ; i++ )
48    {
49	cout<<min(abs(a[i]-a[i-1]),abs(a[i+1]-a[i]))<<" "<<max(abs(a[i]-a[1]),abs(a[n]-a[i]))<<endl;
50    }
51    cout<<a[n]-a[n-1]<<" "<<a[n]-a[1]<<endl;
52	return 0;
53}

Related

cf 443B Kolya and Tandem Repeat

·1 min
B. Kolya and Tandem Repeat time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string.

poj 3279 Fliptile (搜索..暴力?)

·2 mins
http://poj.org/problem?id=3279 反转类问题. 有N*M个方格,每个上面有数字0或者1 操作一个方格,这个方格即其相邻的四个方格(有公共边)会改变状态(由0变1或者由1变0)