• 문제 링크
https://www.acmicpc.net/problem/3058
• 풀이 코드
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));
StringBuilder sb = new StringBuilder();
int t = read();
while (t-- > 0) {
int sum = 0, min = Integer.MAX_VALUE;
for (int i = 0; i < 7; i++) {
int n = read();
if ((n & 1) != 0) continue;
sum += n;
min = Math.min(min, n);
}
sb.append(sum).append(" ").append(min).append("\n");
}
bw.write(sb.toString());
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' 카테고리의 다른 글
[백준] 10812 바구니 순서 바꾸기 - Implementation / Java (0) | 2024.12.26 |
---|---|
[백준] 1568 새 - Implementation / Java (0) | 2024.12.25 |
[백준] 13987 Six Sides - Brute Force / Java (0) | 2024.12.23 |
[백준] 31617 差 (Difference) - Brute Force / Java (0) | 2024.12.22 |
[백준] 15104 Odd Palindrome - Brute Force / Java (0) | 2024.12.21 |
댓글