Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the smallest positive integer m such that the sum of ceil(a_i / m) over a = [7, 11, 12] is at most 9?
- A. 5
- B. 6
- C. 7
- D. 4
Correct answer: D. 4
The sum of ceilings is non-increasing in m, so the first feasible m is found by binary search or a linear scan. Using floor division instead of ceiling changes the answer.
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
- How many ordered pairs (x, y) with 1 <= x, y <= 12 have x y divisible by 12?
- From the multiset [6, 1, 4, 2, 5, 3], choose as many elements as possible (order irrelevant) with total at most 10. What is the maximum…
- How many times does "ab" occur as a substring of the string "aab" repeated three times?
- How many distinct values arise as a sum of two different elements (by position) of [3, 5, 8, 10]?
- For [1, 3, 2, 4, 6, 5, 7], how many positions already hold their correct value in the sorted array?
- How many windows of size 3 in [2, 3, 5, 1, 4, 6, 4] have a sum that is a multiple of 5?