9 solutions

  • -2
    @ 2024-11-30 9:22:25
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,a[3001],b[3000];
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        bool jud;
        if(n==1) cout<<"Not jolly";
        else
        {
            for(int j=1;j<=n-1;j++)
            {
                b[j]=abs(a[j+1]-a[j]);
            }
            for(int k=1;k<=n-2;k++)
            {
                if(b[k+1]-b[k]==1) jud=true;
                else
                {
                    jud=false;
                    break;
                }
            }
            if(jud) cout<<"Jolly";
            else cout<<"Not jolly";
        }
    }
    
    

    Information

    ID
    75
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    143
    Accepted
    47
    Uploaded By