You are viewing a single comment's thread. Return to all comments →
from itertools import product K, M= list(map(int, input().split())) inp= [list(map(int, input().split()))[1::] for _ in range(K)] super_squared_elements = [] for i in inp: squared_elements = [] for j in i: squared_elements.append(j*j) super_squared_elements.append(squared_elements) cartesian_product= list(product(*super_squared_elements)) max_check_appended= [] for val in cartesian_product: max_check_appended.append(sum(val) % M) print(max(max_check_appended))
Seems like cookies are disabled on this browser, please enable them to open this website
Maximize It!
You are viewing a single comment's thread. Return to all comments →