UVA 10038 Solution

using namespace std;
#include<iostream>
int main()
{
    long long last,n,m=0,no=0,val;
    char c;
    bool done[3010]={false},ans;
    while( cin>>no )
    {
           cin>>last;
           for( int l=1;l<no;l++ )
           {
                cin>>n;
               
                if( (last-n)>0)
                    val=(last-n);
                else
                     val=(n-last);
                done[val]=true;
                //cout<<last<<” “<<n<<” “<<val<<”\t”;
                last=n;          
           }
           ans=true;
           for( int i=1;i<no;i++)
           {
                 if( done[i] == false )
                 {
                     //cout<<i<<”\n”;
                     ans=false;
                     break;
                 }
           }
           if ( ans)
               cout<<”Jolly\n”;
           else
                cout<<”Not jolly\n”;
           for(int i=0;i<3010;i++)
                   done[i]=false;
    }
    return 0;
}
               

About these ads

Leave a comment

Filed under uva

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s