Tap here to switch tabs
Problem
Submissions

Problem: Maximize Total Tastiness of Purchased Fruits

Try to solve the Maximize Total Tastiness of Purchased Fruits problem.

Statement

You are given two integer arrays price and tastiness, both of length n, where price[i] and tastiness[i] represent the price and tastiness of the iextthi^{ ext{th}} fruit, respectively. You are also given two integers maxAmount and maxCoupons.

You want to maximize the total tastiness of the fruits you purchase subject to the following rules:

  • You can purchase each fruit at most once.

  • You have a total budget of at most maxAmount.

  • You can use at most maxCoupons discount coupons. Each coupon can be applied to at most one fruit, reducing its price to ⌊\lfloor price[i] /2⌋/ 2 \rfloor.

Return the maximum total tastiness you can obtain.

Constraints:

  • n == price.length == tastiness.length

  • 1≤1 \leq n ≤100\leq 100

  • 0≤0 \leq price[i], tastiness[i], maxAmount ≤1000\leq 1000

  • 0≤0 \leq maxCoupons ≤5\leq 5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Total Tastiness of Purchased Fruits

Try to solve the Maximize Total Tastiness of Purchased Fruits problem.

Statement

You are given two integer arrays price and tastiness, both of length n, where price[i] and tastiness[i] represent the price and tastiness of the iextthi^{ ext{th}} fruit, respectively. You are also given two integers maxAmount and maxCoupons.

You want to maximize the total tastiness of the fruits you purchase subject to the following rules:

  • You can purchase each fruit at most once.

  • You have a total budget of at most maxAmount.

  • You can use at most maxCoupons discount coupons. Each coupon can be applied to at most one fruit, reducing its price to ⌊\lfloor price[i] /2⌋/ 2 \rfloor.

Return the maximum total tastiness you can obtain.

Constraints:

  • n == price.length == tastiness.length

  • 1≤1 \leq n ≤100\leq 100

  • 0≤0 \leq price[i], tastiness[i], maxAmount ≤1000\leq 1000

  • 0≤0 \leq maxCoupons ≤5\leq 5