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.
import math
import os
import random
import re
import sys
#
Complete the 'maximumClusterQuality' function below.
#
The function is expected to return a LONG_INTEGER.
The function accepts following parameters:
1. INTEGER_ARRAY speed
2. INTEGER_ARRAY reliability
3. INTEGER maxMachines
#
def maximumClusterQuality(speed, reliability, maxMachines):
from itertools import combinations
max_quality = 0
n = len(speed)
for r in range(1, maxMachines + 1):
for combo in combinations(range(n), r):
total_speed = sum(speed[i] for i in combo)
min_reliability = min(reliability[i] for i in combo)
quality = total_speed * min_reliability
max_quality = max(max_quality, quality)
return max_quality
Counter game
You are viewing a single comment's thread. Return to all comments →
!/bin/python3
import math import os import random import re import sys
#
Complete the 'maximumClusterQuality' function below.
#
The function is expected to return a LONG_INTEGER.
The function accepts following parameters:
1. INTEGER_ARRAY speed
2. INTEGER_ARRAY reliability
3. INTEGER maxMachines
#
def maximumClusterQuality(speed, reliability, maxMachines): from itertools import combinations
if name == 'main': speed = [3, 6, 1, 3, 4] reliability = [2, 1, 3, 4, 5] maxMachines = 3 print(maximumClusterQuality(speed, reliability, maxMachines))