We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
from itertools import product,combinations
def f(x):
return x**2
k,m=list(map(int,input().split()))
N,L=[],[]
s=0
for i in range(k):
n,*l=list(map(int,input().split()))
N.append(n)
L.append(l)
for i in product(*L):
a=(sum(f(x) for x in i))%m
if a>s: s=a
print(s)
Cookie support is required to access HackerRank
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 →