




'''simple docstring'''




def      a_							(      __snake_case							:			list   ,       __snake_case							:			list   ,       __snake_case							:			int   )							->						int:



       """simple docstring"""
       if len(__snake_case   ) != len(__snake_case   ):
              raise ValueError('''The length of profit and weight must be same.'''   )
       if max_weight <= 0:
              raise ValueError('''max_weight must greater than zero.'''   )
       if any(p < 0 for p in profit   ):
              raise ValueError('''Profit can not be negative.'''   )
       if any(w < 0 for w in weight   ):
              raise ValueError('''Weight can not be negative.'''   )

       # List created to store profit gained for the 1kg in case of each weight
       # respectively.  Calculate and append profit/weight for each element.
       lowerCamelCase_							=[p / w for p, w in zip(__snake_case   ,       __snake_case   )]

       # Creating a copy of the list and sorting profit/weight in ascending order
       lowerCamelCase_							=sorted(__snake_case   )

       # declaring useful variables
       lowerCamelCase_							=len(__snake_case   )
       lowerCamelCase_							=0
       lowerCamelCase_							=0
       lowerCamelCase_							=0

       # loop till the total weight do not reach max limit e.g. 15 kg and till i<length
       while limit <= max_weight and i < length:
              # flag value for encountered greatest element in sorted_profit_by_weight
              lowerCamelCase_							=sorted_profit_by_weight[length - i - 1]
              lowerCamelCase_							=profit_by_weight.index(__snake_case   )
              lowerCamelCase_							=-1

              # check if the weight encountered is less than the total weight
              # encountered before.
              if max_weight - limit >= weight[index]:
                     limit += weight[index]
                     # Adding profit gained for the given weight 1 ===
                     # weight[index]/weight[index]
                     gain += 1 * profit[index]
              else:
                     # Since the weight encountered is greater than limit, therefore take the
                     # required number of remaining kgs and calculate profit for it.
                     # weight remaining / weight[index]
                     gain += (max_weight - limit) / weight[index] * profit[index]
                     break
              i += 1
       return gain


if __name__ == "__main__":
     print(
         """Input profits, weights, and then max_weight (all positive ints) separated by """
         """spaces."""
     )

     a_      :		Optional[int]							      =       [int(x) for x in input("""Input profits separated by spaces: """).split()]
     a_      :		List[str]							      =       [int(x) for x in input("""Input weights separated by spaces: """).split()]
     a_      :		int							      =       int(input("""Max weight allowed: """))

     # Function Call
     calc_profit(profit, weight, max_weight)











from __future__ import annotations


def        SCREAMING_SNAKE_CASE      (       _UpperCAmelCase						,	_UpperCAmelCase )			->     list[tuple[int, int]]:
    lowerCamelCase__ ,							lowerCamelCase__    :      Union[str, Any]					 =		position
    lowerCamelCase__    :      Optional[Any]					 =		[
        (y + 1, x + 2),
        (y - 1, x + 2),
        (y + 1, x - 2),
        (y - 1, x - 2),
        (y + 2, x + 1),
        (y + 2, x - 1),
        (y - 2, x + 1),
        (y - 2, x - 1),
    ]
    lowerCamelCase__    :      Dict					 =		[]

    for position in positions:
        lowerCamelCase__ ,							lowerCamelCase__    :      Optional[int]					 =		position
        if 0 <= y_test < n and 0 <= x_test < n:
            permissible_positions.append(_UpperCAmelCase )

    return permissible_positions


def        SCREAMING_SNAKE_CASE      (       _UpperCAmelCase )			->     bool:
    return not any(elem == 0 for row in board for elem in row )


def        SCREAMING_SNAKE_CASE      (       _UpperCAmelCase						,	_UpperCAmelCase						,	_UpperCAmelCase )			->     bool:

    if is_complete(_UpperCAmelCase ):
        return True

    for position in get_valid_pos(_UpperCAmelCase						,	len(_UpperCAmelCase ) ):
        lowerCamelCase__ ,							lowerCamelCase__    :      Optional[int]					 =		position

        if board[y][x] == 0:
            lowerCamelCase__    :      List[Any]					 =		curr + 1
            if open_knight_tour_helper(_UpperCAmelCase						,	_UpperCAmelCase						,	curr + 1 ):
                return True
            lowerCamelCase__    :      Optional[Any]					 =		0

    return False


def        SCREAMING_SNAKE_CASE      (       _UpperCAmelCase )			->     list[list[int]]:
    lowerCamelCase__    :      Any					 =		[[0 for i in range(_UpperCAmelCase )] for j in range(_UpperCAmelCase )]

    for i in range(_UpperCAmelCase ):
        for j in range(_UpperCAmelCase ):
            lowerCamelCase__    :      Optional[int]					 =		1
            if open_knight_tour_helper(_UpperCAmelCase						,	(i, j)						,	1 ):
                return board
            lowerCamelCase__    :      Optional[Any]					 =		0

    lowerCamelCase__    :      Any					 =		F"""Open Kight Tour cannot be performed on a board of size {n}"""
    raise ValueError(_UpperCAmelCase )


if __name__ == "__main__":
    import doctest

    doctest.testmod()





