Accepted
Code
for i in range(int(input())):
n=int(input())
s=input()
count=0
odd=0
x=0
y=0
for j in range(n):
if s[j]=='0':
count +=1
if s[j]=='1':
odd+=1
for z in range(count):
if s[z]=='1':
x+=1
for k in range(odd):
if s[k]=='0':
y+=1
if x>y:
print(y)
if y>x:
print(x)
if x==y:
print(x)
Information
- Submit By
- Type
- Submission
- Problem
- P1016 Swap sort
- Language
- Python 3 (Python 3.12.3)
- Submit At
- 2024-01-08 05:22:03
- Judged At
- 2024-11-11 03:43:42
- Judged By
- Score
- 100
- Total Time
- 103ms
- Peak Memory
- 3.312 MiB