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.
fromitertoolsimportproductdeff(X,m):result=0forelementinX:result+=element**2returnresult%mdefget_max_combo():num_lists,m=map(int,input().split())#Readlists=[]#initializewheretosaveinthelists# save lists from input into listsforiinrange(num_lists):num_elements,*elements=map(int,input().split())lists.append(elements)# create combinations of every possible list entry with entries from other list entries combos=list(product(*lists))max_f=0forcomboincombos:current_max=f(combo,m)ifcurrent_max>max_f:max_f=current_maxprint(max_f)get_max_combo()
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 →