/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 22ms 3.125 MiB
#2 Accepted 103ms 3.312 MiB
#3 Accepted 30ms 3.137 MiB
#4 Accepted 31ms 3.102 MiB
#5 Accepted 26ms 3.129 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:22:03
Judged At
2024-11-11 03:43:42
Judged By
Score
100
Total Time
103ms
Peak Memory
3.312 MiB