Checkpoint: The Shifting Total
Challenge on lesson: Checkpoint — The Shifting Total
CHALLENGE
Difficulty: advanced+25 XP
**Bài toán.** Given an array a1..an (initially all 0) and q operations: - "1 l r x": add x to every a[i] with l ≤ i ≤ r (0 ≤ x ≤ 1000). - "2 l r": print the current sum a[l] + … + a[r]. **Subtasks:** - Subtask 1 (30 điểm): n, q ≤ 2000. - Subtask 2 (70 điểm): n, q ≤ 2·10^5. All sums fit in 64-bit (at most 2·10^5 updates × 1000 × 2·10^5 elements). **Input:** line 1: n and q; then q lines of operations. **Output:** one line per type-2 operation.
Press Submit to check your solution.
Back to lesson: Checkpoint — The Shifting Total