Skip to main content

Practice · 2 of 6

Budget: 100 queries, huge array

CHALLENGE
Difficulty: advanced+25 XP

**Tình huống.** n ≤ 100000 numbers. q ≤ 100 queries; each asks the median of a range [l, r]. **Thuật toán nào phù hợp nhất? Chương trình chỉ cần in ra chữ cái.** **A)** Build a segment tree answering medians **B)** For each query, copy the range, sort, take the middle (O(q · n log n) total) **C)** Prefix sums of medians **D)** DSU over values

Back to lesson: Practice: Budget Drill Set