This Problem name "Jolly Jumper"
please help me . i try to submit but it wrong answer
#include<iostream>
#include<cmath>
using namespace std;
bool JJump(int dif[] , int n){
for(int i =0 ; i < n-1; i++){
if( dif[i] == 0 || dif[i] >=n ){
return false;
}
}
return true;
}
int main(){
int num[2999];
int diff[2999];
int a;
int i = 0;
while(cin >> a){
i = 0;
for(i = 0 ; i < a ; i++){
cin >> num[i];
}
for(int j =0 ; j < a; j++){
diff[ j-1 ] = fabs( num[ j-1 ]-num[ j ] );
}
if( JJump(diff,a) ){
cout << "Jolly" ;
}
else{
cout << "Not jolly" ;
}
cout << endl;
}
return 0;
}
Last edited on