五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Leetcode 2383. Minimum Hours of Training to Win a Competition

2023-03-14 12:56 作者:您是打尖兒還是住店呢  | 我要投稿

You are entering a competition, and are given two?positive?integers?initialEnergy?and?initialExperience?denoting your initial energy and initial experience respectively.

You are also given two?0-indexed?integer arrays?energy?and?experience,

both of length?n.

You will face?n?opponents?in order.?

The energy and experience of the?ith?opponent is denoted by?energy[i]?and?experience[i]?respectively.

When you face an opponent, you need to have both?strictly?greater experience and energy to defeat them and move to the next opponent if available.

Defeating the?ith?opponent?increases?your experience by?experience[i], but?decreases?your energy by?energy[i].

Before starting the competition,?

you can train for some number of hours.?

After each hour of training, you can?either?choose to increase your initial experience by one, or increase your initial energy by one.

Return?the?minimum?number of training hours required to defeat all?n?opponents.

?

Example 1:

Input: initialEnergy = 5, initialExperience = 3, energy = [1,4,3,2], experience = [2,6,3,1]

Output: 8

Explanation: You can increase your energy to 11 after 6 hours of training,?

and your experience to 5 after 2 hours of training.?

You face the opponents in the following order:?

- You have more energy and experience than the 0th opponent so you win. ?

Your energy becomes 11 - 1 = 10,?

and your experience becomes 5 + 2 = 7.

- You have more energy and experience than the 1st opponent so you win. ?

Your energy becomes 10 - 4 = 6, and your experience becomes 7 + 6 = 13.?

- You have more energy and experience than the 2nd opponent so you win. ?

Your energy becomes 6 - 3 = 3, and your experience becomes 13 + 3 = 16.?

- You have more energy and experience than the 3rd opponent so you win.?

?Your energy becomes 3 - 2 = 1, and your experience becomes 16 + 1 = 17.?

You did a total of 6 + 2 = 8 hours of training before the competition, so we return 8. It can be proven that no smaller answer exists.

Example 2:

Input: initialEnergy = 2, initialExperience = 4, energy = [1], experience = [3]Output: 0Explanation:?

You do not need any additional energy or experience to win the competition, so we return 0.

?

Constraints:

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

  • 1 <= n <= 100

  • 1 <= initialEnergy, initialExperience, energy[i], experience[i] <= 100

一開(kāi)始理解錯(cuò)意思了,其實(shí)就是按順序即可,另一個(gè)就是每次計(jì)算出差異,hours累加。



Runtime:?0 ms, faster than?100.00%?of?Java?online submissions for?Minimum Hours of Training to Win a Competition.

Memory Usage:?41.9 MB, less than?41.15%?of?Java?online submissions for?Minimum Hours of Training to Win a Competition.


Leetcode 2383. Minimum Hours of Training to Win a Competition的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
门头沟区| 竹北市| 城市| 开阳县| 琼中| 陇南市| 金昌市| 荔波县| 尼木县| 岑巩县| 绥阳县| 诸城市| 辽阳县| 灵台县| 阳江市| 虎林市| 西和县| 苏尼特右旗| 白朗县| 临颍县| 曲周县| 绵竹市| 绥棱县| 彝良县| 新泰市| 手机| 利川市| 河北省| 清河县| 湘阴县| 侯马市| 大英县| 灯塔市| 通化县| 禹州市| 仲巴县| 武川县| 嵊泗县| 炉霍县| 天祝| 嘉善县|