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.
# Enter your code here. Read input from STDIN. Print output to STDOUTfromitertoolsimportproductN,M=map(int,input().split())items=[list(map(int,input().split()[1:]))foriinrange(N)]cartesian_product=product(*items,repeat=1)max_val=float('-inf')foritemincartesian_product:summations=sum(list(map(lambdax:x**2,item)))f_x=summations%Miff_x>max_val:max_val=f_xprint(int(max_val))
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 →