Accepted
Code
for _ in range(int(input())):
n = int(input())
s = input()
n1 = s.count('1')
n0 = s.count('0')
c0 = 0
c1 = 0
for i in range(n1):
if s[i]=='1':
continue
else:
c1 += 1
for i in range(n0):
if s[i] == '0':
continue
else:
c0 += 1
print(min(c0, c1))
Information
- Submit By
- Type
- Submission
- Problem
- P1016 Swap sort
- Language
- Python 3 (Python 3.12.3)
- Submit At
- 2024-01-08 17:29:19
- Judged At
- 2024-11-11 03:43:41
- Judged By
- Score
- 100
- Total Time
- 30ms
- Peak Memory
- 3.312 MiB