Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Uses python3
- import sys
- def max_dot_product(p, q):
- # we just sort the two lists
- p.sort()
- q.sort()
- res = 0
- # and multiply them dot for dot
- for i in range(len(p)):
- res += p[i] * q[i]
- return res
- if __name__ == '__main__':
- user_input = sys.stdin.read()
- data = list(map(int, user_input.split()))
- n = data[0]
- a = data[1:(n + 1)]
- b = data[(n + 1):]
- print(max_dot_product(a, b))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement