/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 13ms 3.0 MiB
#2 Accepted 29ms 3.152 MiB
#3 Accepted 14ms 2.895 MiB
#4 Accepted 14ms 2.887 MiB
#5 Accepted 12ms 2.84 MiB

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-01-08 17:29:19
Judged By
Score
100
Total Time
29ms
Peak Memory
3.152 MiB