CompetitiveProgramming/src/bin/cf-1917d.py

12 lines
375 B
Python
Raw Normal View History

2024-01-18 04:40:12 +00:00
from sortedcontainers import SortedList
def solve():
n, k = [int(x) for x in input().strip().split(' ')]
p = [int(x) for x in input().strip().split(' ')]
q = [int(x) for x in input().strip().split(' ')]
assert n == len(p) and k == len(q)
st = SortedList()
res = 0
for i in range(n - 1, -1, -1):
res += st.bisect_left(p[i])
res +=