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
|
1071 Discussions
|
Please Login in order to post a comment
Are all the test cases are correct, some of them are seems wrong mathematically ex: one of the test case input is 1 384 5 899954391 390010037 470009874 789620942 589990574 Expected output is 324 but when we calculate with mathematical expression the answer is 273
I get an answer of 766 for test 10, and I fail. However 766 appears to be the right answer, even when I substitute my code for other's apparently working answers. Broken tests?
k, m = map(int, input().split()) matrix = [] count = 0 def map_square(x): x = i for i in range(k): x= [*map(lambda x: (int(x)**2)%m, input().split())] x.sort() matrix.append(x) matrix.sort(key=lambda x: max(x) )
def calculate_sum_all_elements(matrix:list): if len(matrix) == 1: return max(matrix) else: lst1 = matrix.pop(0) lst2 = matrix.pop(0) lst = [(x+y)%m for x in lst1 for y in lst2] matrix.insert(0, lst) return calculate_sum_all_elements(matrix)
print(max(calculate_sum_all_elements(matrix)))