← 返回 google 的题目列表Range Updates Using Difference Array (Template Problem)
类型:online_judge
Problem (Incomplete; abstracted from description)
You are given an array of length n (either initialized to all zeros or provided). There are q range update operations. Each operation adds delta to every element in the index range [l, r] (whether indices are 0-based or 1-based depends on the original statement):
arr[i] += delta for all l <= i <= r
After all operations, output either:
the final array, or
some statistic of the final array (e.g., maximum value, value at specific indices, answers to queries).
Constraints
Not provided (typically requires a difference array + prefix sum to pass when n,q are large).
Example
Not provided.
Example
Input
5 3
0 1 2
1 3 1
2 4 3
Output
2 3 4 4 3