Tap here to switch tabs
Problem
Submissions

Problem: Mice and Cheese

Mice and Cheese assigns every cheese type to one of two mice, with different rewards for each choice. Find the maximum total reward when the first mouse gets exactly k types.

Statement

There are two mice and nn different types of cheese. Each type of cheese must be eaten by exactly one mouse.

If the first mouse eats the ithi^{ {th}} type of cheese, the mice achieve reward1[i] points. If the second mouse eats the ithi^{ {th}} type of cheese, the mice achieve reward2[i] points.

Given two integer arrays reward1 and reward2 of length nn, and an integer k, return the maximum total points the mice can achieve if the first mouse eats exactly k types of cheese and the second mouse eats the remaining n−kn - k types of cheese.

Constraints:

  • 1≤n==1 \leq n == reward1.length ==== reward2.length ≤105\leq 10^5

  • 1≤1 \leq reward1[i], reward2[i] ≤1000\leq 1000

  • 0≤0 \leq k ≤n\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Mice and Cheese

Mice and Cheese assigns every cheese type to one of two mice, with different rewards for each choice. Find the maximum total reward when the first mouse gets exactly k types.

Statement

There are two mice and nn different types of cheese. Each type of cheese must be eaten by exactly one mouse.

If the first mouse eats the ithi^{ {th}} type of cheese, the mice achieve reward1[i] points. If the second mouse eats the ithi^{ {th}} type of cheese, the mice achieve reward2[i] points.

Given two integer arrays reward1 and reward2 of length nn, and an integer k, return the maximum total points the mice can achieve if the first mouse eats exactly k types of cheese and the second mouse eats the remaining n−kn - k types of cheese.

Constraints:

  • 1≤n==1 \leq n == reward1.length ==== reward2.length ≤105\leq 10^5

  • 1≤1 \leq reward1[i], reward2[i] ≤1000\leq 1000

  • 0≤0 \leq k ≤n\leq n