-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa-10038.cpp
More file actions
51 lines (37 loc) · 906 Bytes
/
UVa-10038.cpp
File metadata and controls
51 lines (37 loc) · 906 Bytes
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
46
47
48
49
50
51
#include <iostream>
#include <cstdio>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#define ALL(x) x.begin(), x.end()
#define FAST std::cin.tie(0); ios::sync_with_stdio(false); std::cout.tie(0);
int main(void) {
FAST
int n;
unordered_set<int> s;
while (cin >> n) {
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
s.clear();
for (int i = 0; i < n - 1; i++) {
s.insert(abs(v[i] - v[i + 1]));
}
bool is_jolly = true;
for (int i = 1; i < n; i++) {
if (s.find(i) == s.end()) {
is_jolly = false;
break;
}
}
if (is_jolly) {
cout << "Jolly" << endl;
} else {
cout << "Not jolly" << endl;
}
}
return 0;
}