diff --git a/zeta_python/completed/10431.py b/zeta_python/completed/10431.py new file mode 100644 index 0000000..baa2330 --- /dev/null +++ b/zeta_python/completed/10431.py @@ -0,0 +1,28 @@ +import sys + +input = sys.stdin.readline + + +def solve(A: list[int]): + A.reverse() + B = [] + cnt = 0 + while A: + a = A.pop() + l = len(B) + for i, b in enumerate(B): + if b > a: + B.insert(i, a) + cnt += l - i + break + else: + B.append(a) + + return cnt + + +if __name__ == "__main__": + T = int(input()) + for _ in range(T): + t, *A = map(int, input().split()) + print(t, solve(A))