Title Description
A n integer array elements, if the difference between two successive array elements include an absolute value of [1, n-1] for all integer, called the matching "joy jump", such as an array 1423 matching " joyful jump ", because the absolute value of the difference are: 3,2,1 .
Given an array, your task is to determine if the array is in line with "Happy jump."
Input Format
Each test line to an integer n (1≤n≤1000) begins next n spaces spaced at [ -10 ^ 8 ^ 8,10 integer] a.
Output Format
For each test case, output one line if the array is in line with "joy jump" output "Jolly", otherwise output "Not jolly".
Sample input and output
Input # 1
4 1 4 2 3
Output # 1
Jolly
Input # 2
5 1 4 2 -1 6
Output # 2
Not jolly
Description / Tips
1≤n≤1000
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n; 6 cin>>n; 7 int a[n]; 8 set<int>num; 9 for(int i=0;i<n;i++){ 10 cin>>a[i]; 11 } 12 for(int i=0;i<n-1;i++){ 13 num.insert(abs(a[i]-a[i+1])); 14 } 15 if(num.size()==n-1&&*num.begin()==1){ 16 cout<<"Jolly"; 17 }else{ 18 cout<<"Not jolly"; 19 } 20 }