Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
What is the smallest positive integer divisor d such that the sum of ceil(x / d) over [1, 2, 5, 9] is at most 6?
- A. 5
- B. 6
- C. 4
- D. 7
Correct answer: A. 5
The sum of ceilings is non-increasing in d, so binary search finds the smallest valid divisor. Using floor division instead of ceiling gives a smaller sum and a wrong divisor.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Sort [6, 3, 4, 1, 2, 5] so that all even numbers come first in increasing order, then all odd numbers in increasing order, using adjacent…
- Each operation doubles one element of [4, 8, 16, 2]. What is the minimum number of operations needed to make all four elements equal?
- For the positive array [2, 1, 3, 4, 1], how many contiguous subarrays have a sum at most 5?
- How many contiguous subarrays of [1, 2, 1, 3, 4, 2, 3] contain exactly 3 distinct values?
- How many contiguous subarrays of [2, 8, 3, 2, 6, 1] have a product that is a perfect square?
- What is the minimum number of characters that must be deleted from "abcbdab" to make it a palindrome?