-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilya and Homework.cpp
More file actions
41 lines (39 loc) · 871 Bytes
/
Filya and Homework.cpp
File metadata and controls
41 lines (39 loc) · 871 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
40
41
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int arr[n];
for(int i = 0; i < n; i++)
cin >> arr[i];
sort(arr, arr + n);
int m = n / 2, temp = arr[m] - arr[0];
for(int i = 0; i < m; i++){
if(arr[i] == arr[m])
continue;
else if(arr[i] + temp == arr[m])
continue;
else{
cout << "NO";
return 0;
}
}
int temp2 = arr[n - 1] - arr[m];
if(temp != temp2 && arr[n - 1] != arr[m]){
cout << "NO";
return 0;
}
temp2 = arr[n - 1] - arr[m];
for(int i = m + 1; i < n; i++){
if(arr[i] == arr[m])
continue;
else if(arr[i] - temp == arr[m])
continue;
else{
cout << "NO";
return 0;
}
}
cout << "YES";
return 0;
}