You are viewing a single comment's thread. Return to all comments →
from itertools import product K, M = list(map(int, input().split())) lists = [] for i in range(K): elements = list(map(int, input().split())) lists.append(elements[1:]) squared_totals = [[e**2 for e in lst] for lst in lists] squared_products = product(*squared_totals) max_s = -1 for prod in squared_products: prod = sum(prod) % M if prod > max_s: max_s = prod print(int(max_s))
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 →