-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaekjoon_16496.java
More file actions
61 lines (42 loc) · 1.52 KB
/
baekjoon_16496.java
File metadata and controls
61 lines (42 loc) · 1.52 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
public class baekjoon_16496 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
List<Integer> arr =new ArrayList<>();
for(int i=0;i<N;i++) {
int num = Integer.parseInt(st.nextToken());
arr.add(num);
}
Collections.sort(arr, (o1, o2) -> {
String a = String.valueOf(o1) + String.valueOf(o2);
String b = String.valueOf(o2) + String.valueOf(o1);
BigDecimal aa = new BigDecimal(a);
BigDecimal bb = new BigDecimal(b);
if(aa.compareTo(bb) < 0) {
return 1;
}
else if(aa.compareTo(bb)== 0) return 0;
else return -1;
});
boolean flag = true;
for(int num : arr) {
if(num != 0) {
flag = false;
break;
}
}
if(flag) {
System.out.println(0);
}
else {
for(int num : arr) {
System.out.print(num);
}
System.out.println();
}
}
}