We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e437a6b commit 25c8b62Copy full SHA for 25c8b62
BAEKJOON/2Silver/비트 우정지수.py
@@ -0,0 +1,29 @@
1
+# 그리디 알고리즘
2
+# https://www.acmicpc.net/problem/12782
3
+
4
+import sys
5
6
+input = sys.stdin.readline
7
+T = int(input())
8
+Q = []
9
10
+for _ in range(T):
11
+ A,B = input().split()
12
+ Q_ = 0
13
+ A_ = {"0":0, "1":0}
14
+ B_ = {"0":0, "1":0}
15
+ for i in range(len(A)):
16
+ if A[i] != B[i]:
17
+ Q_ += 1
18
+ A_[A[i]] += 1
19
+ B_[B[i]] += 1
20
21
+ if A_["0"] and B_["0"]:
22
+ # 비트의 숫자를 바꿔서 해결하려면 2번이 필요하고, 교환은 1번이면 되므로
23
+ # swap 횟수만큼 답에서 빼주면 된다.
24
+ swap = min(A_["0"], B_["0"])
25
+ Q_ -= swap
26
27
+ Q.append(str(Q_))
28
29
+print("\n".join(Q))
BAEKJOON/3Gold/대표 선수.py
@@ -1,4 +1,4 @@
-#
+# 자료 구조, 정렬, 우선순위 큐, 투 포인터
# https://www.acmicpc.net/problem/2461
import sys
0 commit comments