Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
4-liner: heapq.nlargest solution in Clear category for Team Play by Phil15
from typing import List
from heapq import nlargest
def max_score(cut: List[int], bend: List[int], k: int) -> int:
n = len(cut)
cut_indexes = set(nlargest(k, range(n), key=lambda i: cut[i] - bend[i]))
return sum((bend, cut)[i in cut_indexes][i] for i in range(n))
May 13, 2020