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
|
1121 Discussions
|
Please Login in order to post a comment
from itertools import product A, B = map(int, input().split(" "))
appended_list = [] for i in range (1, A+1): K = list(map(int, input().split(" "))) all_list= [n for n in K if n != K[0]] appended_list.append(all_list)
V = list(product(*(appended_list)))
greatest_value = 0 for j in V: add_num = 0 for l in j:
add_num = add_num+l2
current_value = add_num%B if current_value > greatest_value: greatest_value = current_value else: greatest_value = greatest_value
print(greatest_value)
Here's the other method but without taking any inputs for my convenience:
I couldn't find a single easy to understand way, So here is mine with extra comments to make it easier
from itertools import product
num,num1=input().split()
list1=[]
for i in range(int(num)):
max_value=0
for cury in product(*list1):
print(max_value)