https://www.acmicpc.net/problem/2476
1. 아이디어
if - else if - else 조건문을 활용하면 간단하게 해결할 수 있다.
2. 문제풀이
조건 1, 2, 3 순서로 체크해서 상금을 구했다.
3. 코드
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int N = Integer.parseInt(br.readLine());
int max = 0;
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
int C = Integer.parseInt(st.nextToken());
if (A == B && A == C) max = Math.max(max, 10000 + 1000 * A);
else if (A == B) max = Math.max(max, 1000 + 100 * A);
else if (B == C) max = Math.max(max, 1000 + 100 * B);
else if (C == A) max = Math.max(max, 1000 + 100 * C);
else max = Math.max(max, 100 * Math.max(A, Math.max(B, C)));
}
System.out.println(max);
}
}
4. 후기
'코딩테스트 준비 > 백준' 카테고리의 다른 글
[백준] 10987번 - 모음의 개수 [Java] (0) | 2024.12.30 |
---|---|
[백준] 2754번 - 학점계산 [Java] (0) | 2024.12.30 |
[백준] 2475번 - 검증수 [Java] (1) | 2024.12.30 |
[백준] 2420번 - 사파리월드 [Java] (0) | 2024.12.30 |
[백준] 2576번 - 홀수 [Java] (0) | 2024.12.30 |