-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_16496.java
More file actions
26 lines (21 loc) · 865 Bytes
/
BOJ_16496.java
File metadata and controls
26 lines (21 loc) · 865 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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.StringTokenizer;
public class BOJ_16496 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
String[] str = new String[N];
StringTokenizer st = new StringTokenizer(br.readLine());
for(int i=0; i<N; i++) str[i] = st.nextToken();
StringBuilder sb = new StringBuilder();
Arrays.sort(str, (t1,t2) -> {
return new BigDecimal(t2 + t1).compareTo(new BigDecimal(t1 + t2));
});
for(String s : str) sb.append(s);
if(sb.toString().charAt(0) == '0') System.out.println(0);
else System.out.println(sb);
}
}