We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1cce6d6 commit f12ddc7Copy full SHA for f12ddc7
1 file changed
김지호/7주차/260210.py
@@ -0,0 +1,33 @@
1
+# https://www.acmicpc.net/problem/1439
2
+# 뒤집기, 실버5
3
+
4
+import sys
5
+sys.stdin = open("../../../input.txt",'r')
6
7
+S = input()
8
9
+one_count = 0
10
+zero_count = 0
11
12
+index = 0
13
+length = len(S)
14
15
+while index < length:
16
17
+ # index 위치부터 연속된 지역까지 탐색하기
18
+ curr_index = index
19
+ number = S[index] # 초기 숫자
20
21
+ while curr_index < length and number == S[curr_index]:
22
+ curr_index += 1
23
24
+ if number == '0':
25
+ zero_count += 1
26
+ else:
27
+ one_count += 1
28
29
+ index = curr_index
30
31
+# print(f"zero_count : {zero_count}")
32
+# print(f"one_count : {one_count}")
33
+print(min(zero_count,one_count))
0 commit comments