国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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ó)家法律
秦皇岛市| 霸州市| 道孚县| 肃宁县| 饶平县| 光山县| 拜泉县| 滦南县| 泽普县| 北碚区| 沭阳县| 印江| 天峨县| 登封市| 清镇市| 巨野县| 凌海市| 韩城市| 镇江市| 锦屏县| 阿城市| 天柱县| 通海县| 白山市| 泸州市| 平陆县| 从化市| 阿克陶县| 邹平县| 札达县| 通辽市| 武隆县| 孝昌县| 凤冈县| 凤山市| 五河县| 双辽市| 金寨县| 喀喇| 南江县| 松滋市|