Tap here to switch tabs
Problem
Submissions

Problem: Maximum Energy Boost From Two Drinks

Try to solve the Maximum Energy Boost From Two Drinks problem.

Statement

You are given two integer arrays energyDrinkA and energyDrinkB, both of length n, representing the energy boost gained from consuming drink A and drink B across n consecutive hours.

During each hour, you can choose to drink either energy drink A or energy drink B:

  • Consuming energy drink A at hour i provides energyDrinkA[i] energy boost.

  • Consuming energy drink B at hour i provides energyDrinkB[i] energy boost.

If you choose to switch between drinks, you must spend 11 hour to clean your system, during which you receive 00 energy boost.

Return the maximum total energy boost you can achieve across all n hours.

Constraints:

  • n == energyDrinkA.length == energyDrinkB.length

  • 3≤3 \leq n ≤105\leq 10^5

  • 1≤1 \leq energyDrinkA[i], energyDrinkB[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Energy Boost From Two Drinks

Try to solve the Maximum Energy Boost From Two Drinks problem.

Statement

You are given two integer arrays energyDrinkA and energyDrinkB, both of length n, representing the energy boost gained from consuming drink A and drink B across n consecutive hours.

During each hour, you can choose to drink either energy drink A or energy drink B:

  • Consuming energy drink A at hour i provides energyDrinkA[i] energy boost.

  • Consuming energy drink B at hour i provides energyDrinkB[i] energy boost.

If you choose to switch between drinks, you must spend 11 hour to clean your system, during which you receive 00 energy boost.

Return the maximum total energy boost you can achieve across all n hours.

Constraints:

  • n == energyDrinkA.length == energyDrinkB.length

  • 3≤3 \leq n ≤105\leq 10^5

  • 1≤1 \leq energyDrinkA[i], energyDrinkB[i] ≤105\leq 10^5