Data Structures & AlgorithmsVery hardCodeforces Div2 D · binary search on answer

Problem: You binary search the answer x for 'the minimum possible largest sum when an array is split into k contiguous parts'. Which property makes this valid, and what is the complexity?

  1. A. Feasibility is not monotone, so ternary search is required with O(n log n)
  2. B. The answer is always the largest element, so no search is needed
  3. C. Feasibility of x is monotone (if x works, any larger x works), giving O(n log(sum))
  4. D. Use a segment tree, which gives O(n log n) with no monotonicity needed

Correct answer: C. Feasibility of x is monotone (if x works, any larger x works), giving O(n log(sum))

Greedily splitting with capacity x into at most k parts succeeds for every larger x whenever it succeeds for x, so the predicate is monotone. Each check is O(n) and the search space is about the total sum.

More Coding Interview Problems questions

Exams that ask this topic