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

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

LeetCode 2611. Mice and Cheese

2023-04-02 14:52 作者:您是打尖兒還是住店呢  | 我要投稿

There are two mice and?n?different types of cheese, each type of cheese should be eaten by exactly one mouse.

A point of the cheese with index?i?(0-indexed) is:

  • reward1[i]?if the first mouse eats it.

  • reward2[i]?if the second mouse eats it.

You are given a positive integer array?reward1, a positive integer array?reward2, and a non-negative integer?k.

Return?the maximum?points the mice can achieve if the first mouse eats exactly?k?types of cheese.

?

Example 1:

Input: reward1 = [1,1,3,4], reward2 = [4,4,1,1], k = 2

Output: 15

Explanation: In this example, the first mouse eats the 2nd?(0-indexed) and the 3rd?types of cheese, and the second mouse eats the 0th?and the 1st types of cheese. The total points are 4 + 4 + 3 + 4 = 15. It can be proven that 15 is the maximum total points that the mice can achieve.

Example 2:

Input: reward1 = [1,1], reward2 = [1,1], k = 2

Output: 2

Explanation: In this example, the first mouse eats the 0th?(0-indexed) and 1st?types of cheese, and the second mouse does not eat any cheese. The total points are 1 + 1 = 2. It can be proven that 2 is the maximum total points that the mice can achieve.

?

Constraints:

  • 1 <= n == reward1.length == reward2.length <= 105

  • 1 <= reward1[i],?reward2[i] <= 1000

  • 0 <= k <= n

k個(gè)reward1+n-k個(gè)reward2 的最大值,如何取判斷,先將reward1-reward2,排序求出前k個(gè)最大值,然后再加reward2的數(shù)組和,這樣就是k個(gè)reward1 +n-k個(gè)reward2的最大值 了。

Runtime:?13 ms, faster than?100.00%?of?Java?online submissions for?Mice and Cheese.

Memory Usage:?50.5 MB, less than?100.00%?of?Java?online submissions for?Mice and Cheese.


LeetCode 2611. Mice and Cheese的評論 (共 條)

分享到微博請遵守國家法律
永川市| 剑河县| 肥城市| 扬中市| 江口县| 威宁| 达尔| 静海县| 多伦县| 封丘县| 青川县| 峨眉山市| 金昌市| 屏边| 湘西| 庄浪县| 景宁| 和顺县| 遂昌县| 信丰县| 武夷山市| 安远县| 亳州市| 分宜县| 丰城市| 会东县| 木兰县| 左权县| 汾阳市| 安西县| 黄大仙区| 镇原县| 礼泉县| 天门市| 南京市| 马公市| 板桥市| 平远县| 虎林市| 尼勒克县| 万宁市|