• + 0 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

    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
    

    if name == 'main': speed = [3, 6, 1, 3, 4] reliability = [2, 1, 3, 4, 5] maxMachines = 3 print(maximumClusterQuality(speed, reliability, maxMachines))

    fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
    speed_count = int(input().strip())
    
    speed = []
    
    for _ in range(speed_count):
        speed_item = int(input().strip())
        speed.append(speed_item)
    
    reliability_count = int(input().strip())
    
    reliability = []
    
    for _ in range(reliability_count):
        reliability_item = int(input().strip())
        reliability.append(reliability_item)
    
    maxMachines = int(input().strip())
    
    result = maximumClusterQuality(speed, reliability, maxMachines)
    
    fptr.write(str(result) + '\n')
    
    fptr.close()