From 7093f029a8e92ce44361fb04edba163b33781109 Mon Sep 17 00:00:00 2001 From: wwan13 Date: Tue, 14 May 2024 14:22:28 +0900 Subject: [PATCH] =?UTF-8?q?solve=20:=2020365=20=EB=B8=94=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/boj_20365.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 python/boj_20365.py diff --git a/python/boj_20365.py b/python/boj_20365.py new file mode 100644 index 0000000..6b3e7f1 --- /dev/null +++ b/python/boj_20365.py @@ -0,0 +1,28 @@ +import sys + +input = sys.stdin.readline + + +def solution(n, data): + colors = {"R": 0, "B": 0} + colors[data[0]] += 1 + + for i in range(1, n): + if data[i] != data[i-1]: + colors[data[i]] += 1 + + return min(colors["R"], colors["B"]) + 1 + + +def display_result(answer): + print(answer) + + +def main(): + n = int(input()) + data = list(map(str, input().rstrip())) + answer = solution(n, data) + display_result(answer) + + +main()