-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMahmoudTriangle.java
More file actions
36 lines (31 loc) · 1.05 KB
/
MahmoudTriangle.java
File metadata and controls
36 lines (31 loc) · 1.05 KB
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
/**
* Created by MalhotR1 on 05/13/2018.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class MahmoudTriangle {
public static void main(String[] args) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
int N = Integer.parseInt(br.readLine().trim());
String[] in = br.readLine().trim().split(" ");
long[] arr = new long[in.length];
for (int i = 0; i < arr.length; i++) {
arr[i] = Long.parseLong(in[i]);
}
Arrays.sort(arr);
boolean isPossible = false;
for (int i = 0; i < arr.length - 2; i++) {
long a = arr[i] + arr[i+1];
long c = arr[i+2];
if (a > c) {
isPossible = true;
break;
}
}
if (isPossible) System.out.println("YES");
else System.out.println("NO");
}
}
}