#39142: C++


grace951225@gmail.com (cct1225)

學校 : 國立臺中女子高級中學
編號 : 217885
來源 : [218.161.65.1]
最後登入時間 :
2024-02-17 22:34:45
d097. 10038 - Jolly Jumpers -- UVa10038 | From: [218.161.65.1] | 發表日期 : 2024-01-20 22:27

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int a[3001],b[3001];
    while(cin>>n)
    {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(int i=0;i<n-1;i++)
        {
            b[i]=abs(a[i]-a[i+1]);
        }
        sort(b,b+n-1);
        for(int i=0;i<n-1;i++)
        {
            if(b[i]==i+1)
            {
                cnt++;
            }
        }
        if(cnt==n-1)    cout<<"Jolly"<<endl;
        else    cout<<"Not jolly"<<endl;
    }
}
 
ZeroJudge Forum