Maximize It!

Sort by

recency

|

1070 Discussions

|

  • + 1 comment

    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))]))
    
  • + 0 comments

    import itertools

    k,m=map(int,input().split())

    el_list=[]

    for i in range(k):

    el_list.append(list(map(int,input().split()))[1:])
    

    all_possibility = list(itertools.product(*el_list))

    print(max([sum([j**2 for j in i])%m for i in all_possibility]))