Maximize It!

Sort by

recency

|

1071 Discussions

|

  • + 0 comments

    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

  • + 2 comments

    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?

  • + 0 comments

    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)))

  • + 0 comments
    from itertools import product
    K, M = map(int, input().split())
    A = [None]*K
    B = [None]*K
    for x in range(K):
        A[x], B[x] = input().split(' ', 1)
        B[x] = list(map(int, B[x].split()))
    SQ = [[v ** 2 for v in B[x]] for x in range(K)]
    MT = max((sum(x)%M for x in product(*SQ)), default = 0)
    print(MT)
    
  • + 0 comments
    from itertools import product
    
    k, m = list(map(int, input().split()))
    my_list = []
    for i in range(1, k+1):
        my_list.append(list(map(int, input().split()[1:])))
    print(max([sum(x**2 for x in combination) % m for combination in list(product(*my_list))]))