/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 15ms 3.07 MiB
#2 Accepted 35ms 3.234 MiB
#3 Accepted 17ms 3.012 MiB
#4 Accepted 18ms 2.895 MiB
#5 Accepted 16ms 3.039 MiB

Code

def solve():
    n=int(input())
    s=input()
    one=0
    zero=0
    for x in s:
        one+=(x=='1')
        zero+=(x=='0')
    ans1=0
    ans2=0
    for i in range(one):
        if(s[i]=='0'):
            ans1+=1
    for i in range(zero):
        if(s[i]=='1'):
            ans2+=1
    print(min(ans1,ans2))

t = int(input())
for _ in range(t):
    solve()

Information

Submit By
Type
Submission
Problem
P1016 Swap sort
Language
Python 3 (Python 3.12.3)
Submit At
2023-12-10 20:30:23
Judged At
2024-11-11 03:48:58
Judged By
Score
100
Total Time
35ms
Peak Memory
3.234 MiB