-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy path567A - Lineland Mail.cpp
44 lines (39 loc) · 1012 Bytes
/
567A - Lineland Mail.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//problem link:http://codeforces.com/contest/567/problem/A
//status:accepted.
//author : mohand sakr
//
//
#include <iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
int n;
cin>>n;
long long arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
for(int i=0;i<n;i++)
{
long long mini=100000000001;
long long maxi=-10000000001;
if(!i)
{
mini=min(mini,min(abs(arr[i]-arr[n-1]),abs(arr[i]-arr[i+1])));
maxi=max( maxi,max ( abs ( arr[i]-arr[n-1] ),max ( abs( arr[i]-arr[i+1] ) ,abs ( arr[i]-arr[n-1] ) ) ));
}
else if(i==n-1)
{
mini=min(mini,min(abs(arr[i]-arr[i-1]),abs(arr[i]-arr[0])));
maxi=max( maxi,max( abs ( arr[i]-arr[i-1] ),max( abs ( arr[i]-arr[0] ) , abs( arr[i]-arr[n-1] ) ) ) );
}
else{
mini=min(mini,min(abs(arr[i]-arr[i-1]),abs(arr[i]-arr[i+1])));
maxi=max(maxi,max(abs(arr[i]-arr[i-1]),max(abs(arr[i]-arr[i+1]), max(abs(arr[i]-arr[n-1]),abs(arr[i]-arr[0]) )) ) );
}
cout<<mini<<" "<<maxi<<"\n";
}
return 0;
}