Tap here to switch tabs
Problem
Submissions

Problem: Minimum Hours of Training to Win a Competition

med
30 min
Try to solve the Minimum Hours of Training to Win a Competition problem.

Statement

You are preparing to enter a competition against nn opponents, indexed from 00 to n−1n - 1. You are given two integers initialEnergy and initialExperience, along with two integer arrays energy and experience, both of length nn.

To defeat opponent i, your current energy must be strictly greater than energy[i], and your current experience must be strictly greater than experience[i].

When you defeat opponent i:

  • Your energy decreases by energy[i].

  • Your experience increases by experience[i].

Before starting the competition, you can train for any integer number of hours. In one hour of training, you can choose to increase either your energy by 11 or your experience by 11.

Return the minimum total number of training hours needed to defeat all nn opponents in sequence from index 00 to n−1n - 1.

Constraints:

  • n ==== energy.length ==== experience.length

  • 1≤1 \le n ≤100\le 100

  • 1≤1 \le initialEnergy, initialExperience, energy[i], experience[i] ≤100\le 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Hours of Training to Win a Competition

med
30 min
Try to solve the Minimum Hours of Training to Win a Competition problem.

Statement

You are preparing to enter a competition against nn opponents, indexed from 00 to n−1n - 1. You are given two integers initialEnergy and initialExperience, along with two integer arrays energy and experience, both of length nn.

To defeat opponent i, your current energy must be strictly greater than energy[i], and your current experience must be strictly greater than experience[i].

When you defeat opponent i:

  • Your energy decreases by energy[i].

  • Your experience increases by experience[i].

Before starting the competition, you can train for any integer number of hours. In one hour of training, you can choose to increase either your energy by 11 or your experience by 11.

Return the minimum total number of training hours needed to defeat all nn opponents in sequence from index 00 to n−1n - 1.

Constraints:

  • n ==== energy.length ==== experience.length

  • 1≤1 \le n ≤100\le 100

  • 1≤1 \le initialEnergy, initialExperience, energy[i], experience[i] ≤100\le 100