You are viewing a single comment's thread. Return to all comments →
using sparse DP approach
k,m = map(int, input().split()) inp_list = [] for _ in range(k): _, *nums = map(int, input().split()) inp_list.append([x * x % m for x in nums]) curr_results = {0} for li in inp_list: new_results = set() for res in curr_results: for ele in li: new_results.add((res + ele) % m) curr_results = new_results print(max(curr_results))
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 →
using sparse DP approach