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.
- Prepare
- Python
- Itertools
- Maximize It!
- Discussions
Maximize It!
Maximize It!
Sort by
recency
|
1019 Discussions
|
Please Login in order to post a comment
from itertools import *
k,n=input().split() k,n=int(k), int(n)
ele=[input().split()[1:] for _ in range(k)] val=0
prod_arr=product(*ele) for num in prod_arr: res=sum(int(m)**2 for m in num)%n val=max(val, res)
print(val)
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: