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.
Don't forget to Remove the first element of each list, i wasted so much time on an easy question trying to figure it out:
importitertoolslist_count,m=map(int,input().split())arrays=[list(map(int,input().split()[1:]))for_inrange(list_count)]max_combination=0# this will return every single combinationscombinations=itertools.product(*arrays)forcombinationincombinations:result=sum(x**2forxincombination)%mmax_combination=max(max_combination,result)print(max_combination)
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 →
Don't forget to Remove the first element of each list, i wasted so much time on an easy question trying to figure it out: