Skip to content

Instantly share code, notes, and snippets.

@KhaledElshamy
Created February 12, 2017 18:31
Show Gist options
  • Save KhaledElshamy/8cceb61b1ee21fbcc1854262bee8e7fd to your computer and use it in GitHub Desktop.
Save KhaledElshamy/8cceb61b1ee21fbcc1854262bee8e7fd to your computer and use it in GitHub Desktop.
B. Filya and Homework-Codeforces
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)
cin>>a[i];
sort(a.begin(),a.end());
vector<int>::iterator length;
length=unique(a.begin(),a.end());
a.resize(distance(a.begin(),length));
if(a.size()<3)
cout<<"YES"<<endl;
else if(a.size()==3)
{
if(a[0]+a[2]==2*a[1])
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
else
cout<<"NO"<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment