洛谷P1152 欢乐的跳进阶解法

#include<iostream>
#include<algorithm>

using namespace std;
int n;
long long a[1000], b[1000];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++)
	{
		b[i] = a[i + 1] - a[i];
		if (b[i] < 0)
			b[i] = -b[i];
	}
	sort(b, b + n - 1);
	for (int i = 1; i < n; i++)
		if (b[i - 1] != i)
		{
			cout << "Not jolly";
			return 0;
		}
	cout << "Jolly";
	return 0;
}