File size: 570 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
// https://uva.onlinejudge.org/external/100/10038.pdf
#include <iostream>
#include <vector>

using namespace std;

typedef vector<bool> vb;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (cin.eof()) break;
		vector<bool> v(n - 1, false);
		int a;
		cin >> a;
		for (int i = 1; i < n; i++) {
			int b;
			cin >> b;
			int d = abs(a - b) - 1;
			a = b;
			if (d < 0 || d > n - 2) continue;
			v[d] = true;
		}
		bool ok = true;
		for (int i = 0; i < n - 1; i++)
			if (!v[i]) {
				ok = false;
				break;
			}
		cout << (ok ? "Jolly" : "Not jolly") << endl;
	}
}