Little Girl and Maximum Sum
MediumRating 1500CodeforcesIntervals & Sweep Line
Approach hintTry it first, then revealHide
Use a difference array to count how many queries cover each index. The total is then largest when the biggest values sit on the most frequently covered positions, so sort both lists and pair them up.