






def   __lowercase       (			snake_case,	snake_case,	snake_case			):







				"""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.
				__magic_name__		:List[Any]   =   [p / w for p, w in zip(snake_case,	snake_case			)]

				# Creating a copy of the list and sorting profit/weight in ascending order
				__magic_name__		:Tuple   =   sorted(snake_case			)

				# declaring useful variables
				__magic_name__		:str   =   len(snake_case			)
				__magic_name__		:List[str]   =   0
				__magic_name__		:List[str]   =   0
				__magic_name__		:Union[str, Any]   =   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
								__magic_name__		:List[Any]   =   sorted_profit_by_weight[length - i - 1]
								__magic_name__		:int   =   profit_by_weight.index(snake_case			)
								__magic_name__		:Any   =   -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."""
					)

					SCREAMING_SNAKE_CASE__   :      Optional[Any]				=		[int(x) for x in input("""Input profits separated by spaces: """).split()]
					SCREAMING_SNAKE_CASE__   :      Tuple				=		[int(x) for x in input("""Input weights separated by spaces: """).split()]
					SCREAMING_SNAKE_CASE__   :      Union[str, Any]				=		int(input("""Max weight allowed: """))

					# Function Call
					calc_profit(profit, weight, max_weight)









from __future__ import annotations

import math






class _UpperCamelCase				:
			'''simple docstring'''







			def __init__(      self				:			Dict   ,   a				:			int						)				->							None:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Dict					  =							size
				# approximate the overall size of segment tree with given value
				SCREAMING_SNAKE_CASE :   Any					  =							[0 for i in range(0   ,   4 * size						)]
				# create array to store lazy update
				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							[0 for i in range(0   ,   4 * size						)]
				SCREAMING_SNAKE_CASE :   Any					  =							[0 for i in range(0   ,   4 * size						)]  # flag for lazy update
			def 				__UpperCamelCase			(      self				:			Tuple   ,   a				:			int						)				->							int:

				"""simple docstring"""

				return idx * 2
			def 				__UpperCamelCase			(      self				:			str   ,   a				:			int						)				->							int:

				"""simple docstring"""

				return idx * 2 + 1
			def 				__UpperCamelCase			(      self				:			int   ,   a				:			int   ,   a				:			int   ,   a				:			int   ,   a				:			list[int]						)				->							None:

				"""simple docstring"""

				if left_element == right_element:
					SCREAMING_SNAKE_CASE :   int					  =							a[left_element - 1]
				else:
					SCREAMING_SNAKE_CASE :   Optional[int]					  =							(left_element + right_element) // 2
					self.build(self.left(a						)   ,   a   ,   a   ,   a						)
					self.build(self.right(a						)   ,   mid + 1   ,   a   ,   a						)
					SCREAMING_SNAKE_CASE :   List[Any]					  =							max(
					    self.segment_tree[self.left(a						)]   ,   self.segment_tree[self.right(a						)]						)
			def 				__UpperCamelCase			(      self				:			Optional[Any]   ,   a				:			int   ,   a				:			int   ,   a				:			int   ,   a				:			int   ,   a				:			int   ,   a				:			int						)				->							bool:

				"""simple docstring"""

				if self.flag[idx] is True:
					SCREAMING_SNAKE_CASE :   Any					  =							self.lazy[idx]
					SCREAMING_SNAKE_CASE :   List[str]					  =							False
					if left_element != right_element:
						SCREAMING_SNAKE_CASE :   Optional[Any]					  =							self.lazy[idx]
						SCREAMING_SNAKE_CASE :   int					  =							self.lazy[idx]
						SCREAMING_SNAKE_CASE :   Any					  =							True
						SCREAMING_SNAKE_CASE :   List[Any]					  =							True

				if right_element < a or left_element > b:
					return True
				if left_element >= a and right_element <= b:
					SCREAMING_SNAKE_CASE :   Optional[Any]					  =							val
					if left_element != right_element:
						SCREAMING_SNAKE_CASE :   str					  =							val
						SCREAMING_SNAKE_CASE :   str					  =							val
						SCREAMING_SNAKE_CASE :   Tuple					  =							True
						SCREAMING_SNAKE_CASE :   Optional[Any]					  =							True
					return True
				SCREAMING_SNAKE_CASE :   int					  =							(left_element + right_element) // 2
				self.update(self.left(a						)   ,   a   ,   a   ,   a   ,   a   ,   a						)
				self.update(self.right(a						)   ,   mid + 1   ,   a   ,   a   ,   a   ,   a						)
				SCREAMING_SNAKE_CASE :   Optional[int]					  =							max(
				    self.segment_tree[self.left(a						)]   ,   self.segment_tree[self.right(a						)]						)
				return True
			def 				__UpperCamelCase			(      self				:			Dict   ,   a				:			int   ,   a				:			int   ,   a				:			int   ,   a				:			int   ,   a				:			int						)				->							int | float:

				"""simple docstring"""

				if self.flag[idx] is True:
					SCREAMING_SNAKE_CASE :   int					  =							self.lazy[idx]
					SCREAMING_SNAKE_CASE :   List[Any]					  =							False
					if left_element != right_element:
						SCREAMING_SNAKE_CASE :   Optional[Any]					  =							self.lazy[idx]
						SCREAMING_SNAKE_CASE :   Optional[Any]					  =							self.lazy[idx]
						SCREAMING_SNAKE_CASE :   Optional[Any]					  =							True
						SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							True
				if right_element < a or left_element > b:
					return -math.inf
				if left_element >= a and right_element <= b:
					return self.segment_tree[idx]
				SCREAMING_SNAKE_CASE :   Dict					  =							(left_element + right_element) // 2
				SCREAMING_SNAKE_CASE :   Tuple					  =							self.query(self.left(a						)   ,   a   ,   a   ,   a   ,   a						)
				SCREAMING_SNAKE_CASE :   Tuple					  =							self.query(self.right(a						)   ,   mid + 1   ,   a   ,   a   ,   a						)
				return max(a   ,   a						)






			def __str__(      self				:			str						)				->							str:

				"""simple docstring"""

				return str([self.query(1   ,   1   ,   self.size   ,   a   ,   a						) for i in range(1   ,   self.size + 1						)]						)


if __name__ == "__main__":
			a_      =     [1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
			a_      =     15
			a_      =     SegmentTree(size)
			segt.build(1, 1, size, A)
			print(segt.query(1, 1, size, 4, 6))
			print(segt.query(1, 1, size, 7, 11))
			print(segt.query(1, 1, size, 7, 12))
			segt.update(1, 1, size, 1, 3, 111)
			print(segt.query(1, 1, size, 1, 15))
			segt.update(1, 1, size, 7, 8, 235)
			print(segt)