n candidates for a squad. Candidate i has skill skill[i] and endurance endurance[i]. Pick a squad of **at most** max_size different candidates (at least one).
The squad's output is the sum of its members' skills multiplied by the lowest endurance among them.
Return the largest possible output. Since it can be very large, return it modulo 10⁹ + 7 (maximise the output itself, not the remainder).n=4, skill=[3, 8, 2, 6], endurance=[6, 2, 9, 4], max_size=2 → 36
Members 0 and 3 give (3 + 6) · min(6, 4) = 36. The most skilled member, 1, drags endurance down: any squad with them makes at most (8 + 6) · 2 = 28.
n=3, skill=[5, 5, 5], endurance=[3, 3, 3], max_size=3 → 45
Take everyone: (5 + 5 + 5) · 3 = 45.
n=3, skill=[1, 1, 10], endurance=[100, 100, 1], max_size=3 → 200
Members 0 and 1 alone give 2 · 100 = 200: taking everyone is not always better.
n=4, skill=[3, 8, 2, 6], endurance=[6, 2, 9, 4], max_size=2
36
Run checks the first 3 tests in your browser. Submit checks all 40 tests on the server, hidden ones included.