





"""simple docstring"""





from __future__ import annotations
def  __A   (_SCREAMING_SNAKE_CASE     ,   _SCREAMING_SNAKE_CASE     ,   _SCREAMING_SNAKE_CASE			)					->tuple[float, list[float]]:





  """simple docstring"""


  lowerCAmelCase__			:List[Any]											=							list(range(len(_SCREAMING_SNAKE_CASE			)			)			)
  lowerCAmelCase__			:str											=							[v / w for v, w in zip(_SCREAMING_SNAKE_CASE     ,   _SCREAMING_SNAKE_CASE			)]
  index.sort(key=lambda _SCREAMING_SNAKE_CASE			: ratio[i]     ,   reverse=_SCREAMING_SNAKE_CASE			)

  lowerCAmelCase__			:float											=							0
  lowerCAmelCase__			:list[float]											=							[0] * len(_SCREAMING_SNAKE_CASE			)
  for i in index:
    if weight[i] <= capacity:
      lowerCAmelCase__			:Optional[int]											=							1
      max_value += value[i]
      capacity -= weight[i]
    else:
      lowerCAmelCase__			:Tuple											=							capacity / weight[i]
      max_value += value[i] * capacity / weight[i]
      break

  return max_value, fractions


if __name__ == "__main__":
  import doctest

  doctest.testmod()







"""simple docstring"""





def  __A   (_SCREAMING_SNAKE_CASE     ,   _SCREAMING_SNAKE_CASE			)					->float:





  """simple docstring"""


  if discount_rate < 0:
    raise ValueError('Discount rate cannot be negative'			)
  if not cash_flows:
    raise ValueError('Cash flows list cannot be empty'			)
  lowerCAmelCase__			:Union[str, Any]											=							sum(
      cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(_SCREAMING_SNAKE_CASE			)			)
  return round(_SCREAMING_SNAKE_CASE     ,   ndigits=2			)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
