Skip to content

Instantly share code, notes, and snippets.

@ashwch
Created March 3, 2013 00:51
Show Gist options
  • Select an option

  • Save ashwch/5073961 to your computer and use it in GitHub Desktop.

Select an option

Save ashwch/5073961 to your computer and use it in GitHub Desktop.
Jolly Jumpers
/*
Author: Ashwini Chaudhary
Problem: Jolly Jumpers (http://goo.gl/O6I2Y)
UVA Online Judge Problem ID:10038
lang :c++
*/
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define VEC_PRINTER(v,l){for(int po=0;po<l;po++)cout<<v[po]<<" ";}
int main(void){
int n,i,curr,prev,ans;
while(cin >>n){
vector<int> vec;
cin>>prev;
for(i=2;i<=n;i++){
cin >>curr;
vec.push_back(abs(prev-curr));
prev=curr;
}
sort(vec.begin(),vec.end());
ans=0;
for(i=1;i<n;i++){
if(vec[i-1]==i)
ans++;
}
if (ans==n-1)cout <<"Jolly"<<endl;
else cout<< "Not jolly"<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment