Created
July 23, 2016 20:47
-
-
Save minhazmiraz/5bd30163f0dee5a9896b4888656dd9a9 to your computer and use it in GitHub Desktop.
10038 - Jolly Jumpers Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********10038******** | |
* MD. Minhazul Islam | |
* Dept. Of CSE | |
* IIUC | |
*/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main() | |
{ | |
int n,arr[4000],item[4000],i,j,diff=0; | |
while(scanf("%d",&n)==1) | |
{ | |
for(i=1;i<=n;i++) | |
arr[i]=0; | |
for(i=1;i<=n;i++) | |
scanf("%d",&item[i]); | |
if(n!=1) | |
{ | |
for(i=1;i<n;i++) | |
{ | |
diff=abs(item[i]-item[i+1]); | |
if(arr[diff]==0) | |
arr[diff]=1; | |
else | |
{ | |
printf("Not jolly\n"); | |
break; | |
} | |
if(i==(n-1)) | |
{ | |
for(j=1;j<n;j++) | |
{ | |
if(arr[j]==0) | |
{ | |
printf("Not jolly\n"); | |
break; | |
} | |
else if(j==(n-1)) | |
printf("Jolly\n"); | |
} | |
} | |
} | |
} | |
else | |
printf("Jolly\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment