CF714B.Filya and Homework
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.
Filya is given an array of non-negative integers _a_1, _a_2, ..., a__n. First, he pick an integer x and then he adds x to some elements of the array (no more than once), subtract x from some other elements (also, no more than once) and do no change other elements. He wants all elements of the array to be equal.
Now he wonders if it's possible to pick such integer x and change some elements of the array using this x in order to make all elements equal.
今天,刺猬 Filya 第一次去上学!老师布置了一道作业,Filya 无法独立完成,需要你的帮助。
Filya 被给定一个由非负整数组成的数组 a1, a2, …, an。首先,他选择一个整数 x,然后对数组中某些元素(每个元素至多操作一次)加上 x,对另外一些元素(每个元素也至多操作一次)减去 x,而其余元素则保持不变。他希望最终数组中的所有元素都相等。
现在他想知道:是否存在某个整数 x,使得通过上述方式对数组中某些元素进行修改后,能使所有元素相等?
输入格式
The first line of the input contains an integer n (1 ≤ n ≤ 100 000) — the number of integers in the Filya's array. The second line contains n integers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 109) — elements of the array.
输入的第一行包含一个整数 n(1≤n≤100000)—— 表示 Filya 数组中整数的个数。
第二行包含 n 个整数 a1,a2,...,an(0≤ai≤109)—— 数组的元素。
输出格式
If it's impossible to make all elements of the array equal using the process given in the problem statement, then print "NO" (without quotes) in the only line of the output. Otherwise print "YES" (without quotes).
如果无法通过题目描述中的操作使数组的所有元素相等,则在输出的唯一一行中打印 "NO"(不带引号)。否则打印 "YES"(不带引号)。
输入输出样例
输入#1
5 1 3 3 2 1
输出#1
YES
输入#2
5 1 2 3 4 5
输出#2
NO
说明/提示
In the first sample Filya should select x = 1, then add it to the first and the last elements of the array and subtract from the second and the third elements.
在第一个样例中,Filya 应选择 x=1,然后将其加到数组的第一个和最后一个元素上,并从第二个和第三个元素中减去它。
输入解题思路,AI测评打分。不知道怎么写?