Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional

Books have page counts [12, 34, 67, 90, 25, 40, 18] in this fixed order. They are split among K = 3 students so that each student receives a contiguous block of books. What is the smallest possible value of the largest number of pages given to any one student?

  1. A. 173
  2. B. 113
  3. C. 95
  4. D. 90

Correct answer: B. 113

Binary search the answer cap between max(b) and sum(b); a cap is feasible if a greedy pass needs at most K students. The average (sum/K) is only a lower bound, and the largest single book is another, so neither is the answer.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic