Created
March 3, 2013 00:51
-
-
Save ashwch/5073961 to your computer and use it in GitHub Desktop.
Jolly Jumpers
This file contains hidden or 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
| /* | |
| 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