空间换时间
python的同学还是少,我就不详细写了,大家有疑问可以留言一起讨论哦
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
#a.sort()
b.sort()
c.sort()
def find(x, l, r, arr):
while l < r:
mid = l + r >> 1
if arr[mid] > x: r = mid
else: l = mid + 1
return l
ans = 0
cnt = [0] * n
s = [0] * (n + 1)
for i in range(n):
pos = find(b[i], 0, n, c)
cnt[i] = n - pos
for i in range(n - 1 , -1, -1):
s[i] = s[i + 1] + cnt[i]
for i in range(n):
tmp = find(a[i], 0, n, b)
ans += s[tmp]
print(ans)