From a66bd22cea107232fb26613a077110268a5c3467 Mon Sep 17 00:00:00 2001 From: Sungwoo Cho Date: Sat, 18 Oct 2025 10:01:12 +0900 Subject: [PATCH] 251019 1475 --- boj/Random Defense/1475_sungwoo.kt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 boj/Random Defense/1475_sungwoo.kt diff --git a/boj/Random Defense/1475_sungwoo.kt b/boj/Random Defense/1475_sungwoo.kt new file mode 100644 index 0000000..ef27d47 --- /dev/null +++ b/boj/Random Defense/1475_sungwoo.kt @@ -0,0 +1,22 @@ +fun main() { + val roomNumber = readln() + val count = IntArray(10) + + // 각 숫자 카운트 + for (ch in roomNumber) { + val digit = ch - '0' + count[digit]++ + } + + // 6과 9 합쳐서 세트 계산 + val sixNineSet = (count[6] + count[9] + 1) / 2 + + // 6과 9는 제외하고 나머지 숫자 중 최대값 찾기 + var maxCount = sixNineSet + for (i in 0..9) { + if (i == 6 || i == 9) continue + maxCount = maxOf(maxCount, count[i]) + } + + println(maxCount) +} \ No newline at end of file