mercredi 14 octobre 2020

Tell me how I complete my code for rest of the test cases(HACKERRANK)

Hacker rank question-MAXIMIZE IT

I have build my logic in such a manner that I passed 13 test cases out of 17.

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

lis3=[]
for i in range(k):
    l = list(map(int,input().split()))
    lis3.append(l)

import random
ls =[]
for _ in range(1000):
    sum = 0
    for i in lis3:
        a = random.choice(i)
        sum = sum+a**2
    sum = sum%m
    ls.append(sum)
print(max(ls))



Aucun commentaire:

Enregistrer un commentaire