我的代码:
#include <iostream>
#include <algorithm>
using namespace std;
int a[1005];
int b[1005];
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
for (int i = 1; i <= n - 1; ++i)
{
if (a[i] - a[i + 1] < 0)
{
b[i] = -(a[i] - a[i + 1]);
}
else
{
b[i] = a[i] - a[i + 1];
}
}
sort(b + 1, b + n);
bool f = 1;
for (int i = 1; i <= n; ++i)
{
if (b[i] != i) f = 0;
}
if (f) cout << "Jolly";
else cout << "Not jolly";
}