File size: 879 Bytes
c4b0eef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
  >>~~ UVa Online Judge ACM Problem Solution ~~<<

  ID: 10038
  Name: Jolly Jumpers
  Problem: https://onlinejudge.org/external/100/10038.pdf
  Language: C++

  Author: Arash Shakery
  Email: arash.shakery@gmail.com
*/

#include <stdio.h>
#include <cstring>
#include <iostream>
using namespace std;

int sub(int a, int b) {
    return a<b ? b-a : a-b;
}

bool bl[3001];
int main(){
    int n;
    while(cin>>n) {
        int cnt=0;
        if (!n) cout << "Jolly\n";
        else {
            for (int i=1; i<=n; i++)
                bl[i]=false;

            int x, y;
            cin >> x;
            for(int i=1; i<n; i++) {
                cin>>y;
                int d = sub(x, y);
                if (d>0 && d<n && !bl[d])
                    bl[d] = ++cnt;
                x = y;
            }
        }
        cout << ((cnt==n-1)?"Jolly\n":"Not jolly\n");
    }
}