#SRD0000015. Cập nhật thưa (Sparse update)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cập nhật thưa (Sparse update)
Sparse update
Source: MarisaOJ
Version: Phuoc Hung OJ Extended
Problem Statement
An integer array of length is initially filled with zeros. Each of the updates specifies integers , with and divisible by .
The update affects only positions
The increments are not constant: increase by , by , and in general, increase by :
$$A_i\leftarrow A_i+\frac{i-l}{d}+1\quad\text{for }i=l+td.$$All other positions stay unchanged. Compute the complete array after all updates. Updates may overlap and their contributions add together.
Input
The first line contains . Each of the next lines contains three integers l r d.
Output
Print the integers in index order, separated by spaces.
Subtasks
- Subtask 1 (15 points): ; ; ; ; .
- Subtask 2 (20 points): ; ; ; ; .
- Subtask 3 (25 points): ; ; ; ; .
- Subtask 4 (40 points): ; ; ; ; .
Examples
Input
5 2
1 5 2
2 2 3
Output
1 1 2 0 3
Explanation
Update 1 5 2 touches positions and adds , giving . Update 2 2 3 touches only position and adds . Thus the final array is . Even though in the second update, means there is only one increment.