-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_21177.java
More file actions
28 lines (23 loc) · 758 Bytes
/
Copy pathBOJ_21177.java
File metadata and controls
28 lines (23 loc) · 758 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
// BOJ - 21177
// Problem Sheet - https://www.acmicpc.net/problem/21177
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] cards = Arrays.stream(br.readLine().split(" "))
.mapToInt(Integer::parseInt)
.sorted()
.toArray();
long totalSum = cards[0];
for (int i=1 ; i<n ; i++) {
if (cards[i] - 1 == cards[i - 1]) {
continue;
}
totalSum += cards[i];
}
System.out.println(totalSum);
br.close();
}
}