summaryrefslogtreecommitdiff
path: root/10038
diff options
context:
space:
mode:
authorAditya Naik2018-05-10 21:21:04 -0400
committerAditya Naik2018-05-10 21:21:04 -0400
commitf4e3a56848cf90ca62cd92df366ea0eecfe4b856 (patch)
tree7e2a5c14351f7a83461428187daa88c157b98222 /10038
parent8a06a8c94f843e19c1e1729faede6c5f34178ba9 (diff)
jolly
Diffstat (limited to '10038')
-rw-r--r--10038/jolly.cpp26
-rw-r--r--10038/jolly.in12
2 files changed, 38 insertions, 0 deletions
diff --git a/10038/jolly.cpp b/10038/jolly.cpp
new file mode 100644
index 0000000..53625e1
--- /dev/null
+++ b/10038/jolly.cpp
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <math.h>
+using namespace std;
+
+int main(){
+ int n;
+ while(cin>>n){
+ int nums[3000], diffs[2999]={0}, i;
+ bool jolly=true;
+ for(i=0; i<n; i++)
+ cin>>nums[i];
+ for(i=1; i<n; i++)
+ diffs[abs(nums[i]-nums[i-1])]=1;
+ for(i=1; i<n; i++){
+ if(diffs[i]==0){
+ jolly=false;
+ break;
+ }
+ }
+ if(jolly)
+ cout<<"Jolly\n";
+ else
+ cout<<"Not jolly\n";
+ }
+ return 0;
+}
diff --git a/10038/jolly.in b/10038/jolly.in
new file mode 100644
index 0000000..85b39f4
--- /dev/null
+++ b/10038/jolly.in
@@ -0,0 +1,12 @@
+1 2000
+5 1 4 2 -1 6
+2 1999 1998
+4 1 4 2 3
+4 1 3 2 -2
+4 1 4 3 5
+4 1 2 5 7
+3 4 1 3
+4 1 4 2 3
+4 1 2 3 6
+2 1 3
+1 1 \ No newline at end of file