Tap here to switch tabs
Problem
Submissions

Problem: Minimum Amount of Damage Dealt to Bob

Minimum Amount of Damage Dealt to Bob gives enemy damage and health arrays and Bob's power. Choose whom to attack while all survivors deal damage. Return minimum total damage received before all fall.

Statement

You are given an integer power and two integer arrays, damage and health, both of length nn.

Bob is facing nn enemies. The iextthi^{ ext{th}} enemy has health[i] health and deals damage[i] points of damage to Bob every second.

Every second, Bob can choose one enemy to attack, reducing their health by power. An enemy is defeated once their health reaches 00 or less, after which they can no longer inflict damage. During each second, all surviving enemies deal damage to Bob simultaneously.

Return the minimum total damage inflicted on Bob before all enemies are eliminated.

Constraints:

  • 1≤1 \leq power ≤104\leq 10^4

  • 1≤n==1 \leq n == damage.length ==== health.length ≤105\leq 10^5

  • 1≤1 \leq damage[i], health[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Amount of Damage Dealt to Bob

Minimum Amount of Damage Dealt to Bob gives enemy damage and health arrays and Bob's power. Choose whom to attack while all survivors deal damage. Return minimum total damage received before all fall.

Statement

You are given an integer power and two integer arrays, damage and health, both of length nn.

Bob is facing nn enemies. The iextthi^{ ext{th}} enemy has health[i] health and deals damage[i] points of damage to Bob every second.

Every second, Bob can choose one enemy to attack, reducing their health by power. An enemy is defeated once their health reaches 00 or less, after which they can no longer inflict damage. During each second, all surviving enemies deal damage to Bob simultaneously.

Return the minimum total damage inflicted on Bob before all enemies are eliminated.

Constraints:

  • 1≤1 \leq power ≤104\leq 10^4

  • 1≤n==1 \leq n == damage.length ==== health.length ≤105\leq 10^5

  • 1≤1 \leq damage[i], health[i] ≤104\leq 10^4