• 문제 링크
1233번: 주사위
지민이는 주사위 던지기 게임을 좋아하여 어느 날 옆에 있는 동호를 설득하여 주사위 던지기 게임을 하자고 하였다. 총 3개의 주사위가 있다. 그리고 이 주사위는 각각 S1(2 ≤ S1 ≤ 20), S2(2 ≤ S2
www.acmicpc.net
• 풀이 코드
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 a = read(), b = read(), c = read();
int[] arr = new int[a + b + c + 1];
for (int i = 1; i <= a; i++)
for (int j = 1; j <= b; j++)
for (int k = 1; k <= c; k++)
arr[i + j + k]++;
int max = 0, res = 0;
for (int i = 3; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
res = i;
}
}
bw.write(String.valueOf(res));
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' 카테고리의 다른 글
[백준] 13410 거꾸로 구구단 - Brute Force / Java (0) | 2023.12.27 |
---|---|
[백준] 1773 폭죽쇼 - Brute Force / Java (0) | 2023.12.26 |
[백준] 14697 방 배정하기 - Brute Force / Java (0) | 2023.12.24 |
[백준] 30019 강의실 예약 시스템 - Greedy / Java (0) | 2023.12.23 |
[백준] 11968 High Card Wins - Greedy / Java (0) | 2023.12.22 |
댓글