Skip to main content

Range Assign, Range Sum

Challenge on lesson: Checkpoint — Lazy Segment Tree

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** n numbers, q operations: 1 l r v assigns v to every element of [l, r]; 2 l r prints the sum of [l, r]. **Constraints:** 1 ≤ n, q ≤ 200 000; 0 ≤ v ≤ 10^9; initial |a[i]| ≤ 10^9. Requires a lazy segment tree — O(n) per operation will not fit.

Back to lesson: Checkpoint — Lazy Segment Tree