Skip to main content

Practice · 1 of 8

Range Add, Range Sum

CHALLENGE
Difficulty: advanced+25 XP

**Tình huống.** An array of n ≤ 200000 integers. q ≤ 200000 operations, interleaved: 1 l r x adds x to every a[l..r]; 2 l r prints the sum of a[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)** Static prefix sums, rebuilt after each update **B)** Fenwick tree (two-BIT range trick) or lazy segment tree **C)** Dijkstra from node l **D)** Sort the array and use two pointers

Back to lesson: Practice: Recognition Drill Set 1