#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, i, c, j, f;
while(cin >> n)
{
int a[n], b[n];
for(i=0; i<n; i++)
{
cin >> a[i];
}
f = 0;
for(i=0; i<n-1; i++)
{
c = abs(a[i]-a[i+1]);
if(c<1 || c>n-1)
{
f = 1;
cout << "Not jolly" << endl;
break;
}
b[i] = c;
}
if(f != 1)
{
sort(b, b+i);
for(j=0; j<=i; j++)
{
if(b[j] == b[j+1])
{
f = 1;
cout << "Not jolly" << endl;
break;
}
}
}
if(f == 0)
cout << "Jolly" << endl;
}
return 0;
}
using namespace std;
int main()
{
int n, i, c, j, f;
while(cin >> n)
{
int a[n], b[n];
for(i=0; i<n; i++)
{
cin >> a[i];
}
f = 0;
for(i=0; i<n-1; i++)
{
c = abs(a[i]-a[i+1]);
if(c<1 || c>n-1)
{
f = 1;
cout << "Not jolly" << endl;
break;
}
b[i] = c;
}
if(f != 1)
{
sort(b, b+i);
for(j=0; j<=i; j++)
{
if(b[j] == b[j+1])
{
f = 1;
cout << "Not jolly" << endl;
break;
}
}
}
if(f == 0)
cout << "Jolly" << endl;
}
return 0;
}
Comments
Post a Comment