/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 15ms 3.02 MiB
#2 Accepted 55ms 3.285 MiB
#3 Accepted 17ms 3.02 MiB
#4 Accepted 18ms 3.086 MiB
#5 Accepted 15ms 3.109 MiB

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:21:44
Judged At
2024-11-11 03:43:42
Judged By
Score
100
Total Time
55ms
Peak Memory
3.285 MiB