2611. Mice and Cheese Medium
1/**
2 * [2611] Mice and Cheese
3 *
4 * There are two mice and n different types of cheese, each type of cheese should be eaten by exactly one mouse.
5 * A point of the cheese with index i (0-indexed) is:
6 *
7 * reward1[i] if the first mouse eats it.
8 * reward2[i] if the second mouse eats it.
9 *
10 * You are given a positive integer array reward1, a positive integer array reward2, and a non-negative integer k.
11 * Return the maximum points the mice can achieve if the first mouse eats exactly k types of cheese.
12 *
13 * <strong class="example">Example 1:
14 *
15 * Input: reward1 = [1,1,3,4], reward2 = [4,4,1,1], k = 2
16 * Output: 15
17 * Explanation: In this example, the first mouse eats the 2^nd (0-indexed) and the 3^rd types of cheese, and the second mouse eats the 0^th and the 1^st types of cheese.
18 * The total points are 4 + 4 + 3 + 4 = 15.
19 * It can be proven that 15 is the maximum total points that the mice can achieve.
20 *
21 * <strong class="example">Example 2:
22 *
23 * Input: reward1 = [1,1], reward2 = [1,1], k = 2
24 * Output: 2
25 * Explanation: In this example, the first mouse eats the 0^th (0-indexed) and 1^st types of cheese, and the second mouse does not eat any cheese.
26 * The total points are 1 + 1 = 2.
27 * It can be proven that 2 is the maximum total points that the mice can achieve.
28 *
29 *
30 * Constraints:
31 *
32 * 1 <= n == reward1.length == reward2.length <= 10^5
33 * 1 <= reward1[i], reward2[i] <= 1000
34 * 0 <= k <= n
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/mice-and-cheese/
40// discuss: https://leetcode.com/problems/mice-and-cheese/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn mice_and_cheese(reward1: Vec<i32>, reward2: Vec<i32>, k: i32) -> i32 {
46 0
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_2611() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.