-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSolution-CF567-D2-A
46 lines (43 loc) · 1.17 KB
/
Solution-CF567-D2-A
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
45
46
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
int n=0;
cin>>n;
int allCordinates[n];
for(int i=0;i<n;i++){
cin>>allCordinates[i];
}
for(int i=0;i<n;i++){
int minValue=0;
int maxValue=0;
if(i==0){
minValue=abs(allCordinates[i]-allCordinates[i+1]);
maxValue=abs(allCordinates[i]-allCordinates[n-1]);
}
else if(i==(n-1)){
minValue=abs(allCordinates[i]-allCordinates[i-1]);
maxValue=abs(allCordinates[i]-allCordinates[0]);
}
else{
int temp1=abs(allCordinates[i]-allCordinates[i-1]);
int temp2=abs(allCordinates[i]-allCordinates[i+1]);
if(temp1>=temp2){
minValue=temp2;
}else{
minValue=temp1;
}
int temp3=abs(allCordinates[i]-allCordinates[n-1]);
int temp4=abs(allCordinates[i]-allCordinates[0]);
if(temp3>=temp4){
maxValue=temp3;
}else{
maxValue=temp4;
}
}
cout<<minValue<<" "<<maxValue<<endl;
}
return 0;
}