/
Problem10038.java
39 lines (37 loc) · 1.13 KB
/
Problem10038.java
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
import java.lang.Integer;
import static java.lang.Math.abs;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Problem10038 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
//int n = sc.nextInt();
while(sc.hasNextInt()) {
int[] v = new int[2];
//Set<Integer> found = new HashSet<Integer>();
Set<Integer> found = new TreeSet<Integer>();
boolean second = false;
int n = sc.nextInt();
for(int i = 0; i < n; i++) {
v[i % 2] = sc.nextInt();
if (second)
found.add(abs(v[0] - v[1]));
else
second = true;
}
boolean wasFound = true;
for (int i = 1; i < n; i++) {
if (!found.contains(i)) {
wasFound = false;
break;
}
}
if (wasFound)
System.out.println("Jolly");
else
System.out.println("Not jolly");
}
}
}