/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 13ms 2.879 MiB
#2 Time Exceeded ≥2005ms ≥3.738 MiB
#3 Time Exceeded ≥2012ms ≥2.902 MiB
#4 Wrong Answer 219ms 2.891 MiB
#5 Accepted 20ms 2.703 MiB

Code

t=int(input())
if 1 <= t <= 1000:
    for i in range(t):
        n = int(input())
        s = input()
        count = 0
        odd = 0
        S = list(s)
        if 1<=n<=10**5:
            for j in range(n):
                if S[j] == '0':
                    for c in range(j + 1, n):
                        if S[c] == '1':
                            S[j], S[c] = S[c], S[j]
                            count += 1

            for k in range(n):
                if S[k] == '1':
                    for b in range(k + 1, n):
                        if S[b] == '0':
                            S[k], S[b] = S[b], S[k]
                            odd += 1

            if count < odd:
                print(count)
            elif odd < count:
                print(odd)
            elif odd == count:
                print(odd)

Information

Submit By
Type
Submission
Problem
P1016 Swap sort
Language
Python 3 (Python 3.12.3)
Submit At
2024-01-07 15:26:03
Judged At
2024-01-26 22:58:48
Judged By
Score
40
Total Time
≥2012ms
Peak Memory
≥3.738 MiB