Part 3.5b
~40 min read
Intermediate
Chapter 3.5b: Binary Search on Answer
English translation of this chapter is coming soon. Please refer to the Chinese version for now.
Content Outline
3.5b.1 What is Binary Search on Answer?
- From Brute Force to Binary Search
3.5b.2 Three Key Elements of Binary Search on Answer
- Answer within a Fixed Range
- Easy-to-Implement Check Function
- Monotonicity
- Two Forms of Monotonicity
3.5b.3 Integer Binary Search Templates
- Template A: Find the Maximum Satisfying Value (Maximization)
- Template B: Find the Minimum Satisfying Value (Minimization)
- Why
lo + 1 < hiinstead oflo < hi?
3.5b.4 Complete Example: Cutting Wood
3.5b.5 Example: Maximize the Minimum (Placing Cows)
3.5b.6 Floating-Point Binary Search
3.5b.7 Ternary Search (Finding Extrema of Unimodal Functions)
3.5b.8 Binary Search on Answer vs Binary Search
Common Mistakes
Exercises
- Cutting Ropes (Floating-Point Binary Search)
- Array Partitioning (Minimize Maximum)
- K-th Smallest Element in a Sorted Matrix
- Placing Cows (Maximize Minimum Distance)
- Jumping Rocks (NOIP 2015)
- Optimal Ratio (Fractional Programming)
- Minimize Maximum Cost (Binary Search + Graph)
- Minimize Total Waiting Time (Binary Search + Greedy)