-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_15008.java
More file actions
35 lines (29 loc) · 939 Bytes
/
Copy pathBOJ_15008.java
File metadata and controls
35 lines (29 loc) · 939 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
// BOJ - 15008
// Problem Sheet - https://www.acmicpc.net/problem/15008
import java.util.*;
import java.io.*;
public class Main {
private static int n;
private static int[] arr;
public static void main(String[] args) throws IOException {
input();
System.out.println(solve());
}
private static void input() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(br.readLine());
arr = Arrays.stream(br.readLine().split(" "))
.mapToInt(Integer::parseInt)
.sorted()
.toArray();
br.close();
}
private static String solve() {
int alice = 0, bob = 0;
for (int i=0 ; i<n ; i++) {
if (i % 2== 0) alice += arr[n - 1 - i];
else bob += arr[n - 1 - i];
}
return String.format("%d %d", alice, bob);
}
}