HackerRank Python - Maximize It
You have to pick one element from each list so that the value from the equation below is maximized:
- # Enter your code here. Read input from STDIN. Print output to STDOUT
-
- from itertools import product
-
- k, m = map(int, input().split())
-
- array = []
- for _ in range(k):
- array.append(list(map(int, input().split()))[1:])
-
- result = 0
- for combination in product(*array):
- result = max(sum([x * x for x in combination]) % m, result)
- print(result)