-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Lineland_Mail.cpp
More file actions
39 lines (33 loc) · 822 Bytes
/
Copy pathA_Lineland_Mail.cpp
File metadata and controls
39 lines (33 loc) · 822 Bytes
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
////https://codeforces.com/contest/567/problem/A
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
void solve(){
int n;cin>>n;
vector <int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
for(int i=0;i<n;i++){
if(i==0){
cout<<abs(v[i]-v[i+1])<<" "<<abs(v[i]-v[n-1])<<endl;
}
else if(i==n-1){
cout<<abs(v[i]-v[i-1])<<" "<<abs(v[i]-v[0])<<endl;
}
else {
//for min
int left=abs(v[i]-v[i-1]);
int right=abs(v[i]-v[i+1]);
//for max
int left1=abs(v[i]-v[0]);
int right1=abs(v[i]-v[n-1]);
cout<<min(left,right)<<" "<<max(left1,right1)<<endl;
}
}
}
int main() {
solve();
}