LCC '18 Contest 4 J1 - Terminus Quest

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
_
Problem type

On his quest to solve Terminus Est, Max finds an ancient scroll that claims to be the key to solving the problem.

The scroll proclaims:

The one to solve Terminus Est shall be able to recognize patterns.

Max interprets this as the ability to recognize arithmetic patterns.

Max defines an arithmetic pattern as a list (\(a\)) of \(N\) integers where the difference between any adjacent pair is the same.

The difference of an adjacent pair of integers is defined as \(a_i - a_{i - 1}\) for all \(i\), \(2 \le i \le N\).

Can you determine if a list of numbers is an arithmetic pattern?

Input Specification

The first line contains a single integer, \(N\). \(2 \leq N \leq 1000\).

The next line describes the list of numbers by providing \(N\) space separated integers where the \(i\)th integer describes \(a_i\). \(0 \leq a_i \leq 10^6\)

Output Specification

YES if the input list is an arithmetic pattern. NO if the input list is not an arithmetic pattern.

Sample Input

5
2 4 6 8 10

Sample Output

YES

Comments

There are no comments at the moment.