/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 19ms 3.008 MiB
#2 Accepted 97ms 3.312 MiB
#3 Accepted 25ms 3.137 MiB
#4 Accepted 29ms 3.129 MiB
#5 Accepted 21ms 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-21 18:58:21
Judged At
2024-11-11 03:43:28
Judged By
Score
100
Total Time
97ms
Peak Memory
3.312 MiB