-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCF653ABearAndThreeBalls.java
More file actions
45 lines (39 loc) · 946 Bytes
/
CF653ABearAndThreeBalls.java
File metadata and controls
45 lines (39 loc) · 946 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
/**
* See <a href="http://codeforces.com/problemset/problem/653/A">Bear and Three
* Balls</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class CF653ABearAndThreeBalls {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
in.readLine();
int[] t = Arrays.stream(in.readLine().split("\\s"))
.distinct()
.mapToInt(Integer::parseInt)
.sorted()
.toArray();
if (t.length < 3) {
out.print("NO");
} else {
int i = 0;
int l = t.length;
while (i <= l - 3) {
if (t[i + 2] - t[i] == 2) {
out.print("YES");
out.close();
break;
}
i++;
}
out.print("NO");
}
out.close();
}
}