Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D
In a 3 × 5 multiplication table (entries i × j for 1 ≤ i ≤ 3, 1 ≤ j ≤ 5), with repeats counted, what is the 7-th smallest entry?
- A. 4
- B. 5
- C. 6
- D. 3
Correct answer: A. 4
Binary search a value x and count entries ≤ x, which is Σ over rows i of min(n, floor(x/i)). The smallest x with count ≥ k is the answer; reading off the k-th row or column directly gives a different entry.
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
- Flowers bloom on the days [1, 10, 3, 10, 2] (one flower per position). You need m = 3 bouquets, and each bouquet needs k = 1 adjacent…
- Wood sticks have lengths [232, 124, 456] (integers). You need K = 7 pieces of EQUAL integer length, and you may cut each stick into as…
- How many unordered pairs of positions (i < j) in [9, 1, 6, 14, 3, 11, 7] have an absolute difference of at most 4?
- For the multiset [1, 6, 1, 9, 4, 12, 3], consider all unordered pairs of distinct positions and their absolute differences. What is the…
- What is the smallest non-negative integer x for which x³ + x is at least 1000?
- A binary search for the FIRST index where a predicate becomes true uses: lo = 0, hi = n, while lo < hi: mid = (lo + hi) // 2; if…