Python | Maximize It! | Hackerrank Solution

preview_player
Показать описание
#maximizeit
#maximizeitpython
#maximizeithackerrank
#maximizeithackerranksolution
#python
#hackerrank

Python Hackerrank Challenge Tutorial
Itertools - Maximize It!
Рекомендации по теме
Комментарии
Автор

Why pick the max of each set will not be the max of sum(f(x))
K, M=input().split()
k=int(K)
m=int(M)
maxinset=[ ]

for i in range(k):
listi=list(map(int, input().split()))
a=max(listi[1:])
maxinset.append(a)

square=[x**2 for x in maxinset]
result=sum(square)%m
print(result)

this code can pas 4 test cases, I caculate one more manually of the not passed cased, still my result is correct. I see your code is correct, cannot have an example why pick the max of one set is not the solution.

zhengxijiang