/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 14ms 3.102 MiB
#2 Accepted 30ms 3.312 MiB
#3 Accepted 15ms 3.062 MiB
#4 Accepted 16ms 3.102 MiB
#5 Accepted 14ms 3.125 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-11-11 03:43:41
Judged By
Score
100
Total Time
30ms
Peak Memory
3.312 MiB