• 문제 링크
https://www.acmicpc.net/problem/28062
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = read(), sum = 0, min = Integer.MAX_VALUE;
while (n-- > 0) {
int i = read();
sum += i;
if ((i & 1) == 1) min = Math.min(min, i);
}
bw.write(String.valueOf(sum - ((sum & 1) == 0 ? 0 : min)));
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 1252 이진수 덧셈 - Implementation / Java (1) | 2025.07.08 |
---|---|
[백준] 11655 ROT13 - Implementation / Java (0) | 2025.07.07 |
[백준] 31067 다오의 경주 대회 - Greedy / Java (0) | 2025.07.05 |
[백준] 28470 슥~빡! 빡~슥! - Greedy / Java (0) | 2025.07.04 |
[백준] 29891 체크포인트 달리기 - Greedy / Java (0) | 2025.07.03 |
댓글