#SRD0000017. Bãi chứa công-ten-nơ (Shipping Containers)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Bãi chứa công-ten-nơ (Shipping Containers)
Shipping Containers
Source: Szkopuł
Version: Phuoc Hung OJ Extended
Problem Statement
A loading wharf consists of consecutive positions, numbered from to . Initially, every position contains shipping containers, and any number of containers may be stacked at the same position.
There are crane operations. Operation is described by : the crane places exactly one container at each position
$$a_i,\ a_i+d_i,\ a_i+2d_i,\ldots,\ a_i+(\ell_i-1)d_i.$$Hence the operation places containers. The final selected position is guaranteed not to exceed . When , the input guarantees .
After all operations, compute the number of containers at every position through . Each selected position receives a constant increment of 1, unlike the increasing increments in Sparse update.
Input
The first line contains . Each of the next lines contains positive integers a len d, where len denotes .
Output
Print space-separated integers: the number of containers at each position after all operations, in ascending index order.
Subtasks
- Subtask 1 (15 points): ; ; ; ; nếu thì .
- Subtask 2 (20 points): ; ; ; ; nếu thì .
- Subtask 3 (25 points): ; ; ; ; nếu thì .
- Subtask 4 (40 points): ; ; ; ; nếu thì .
Examples
Input
8 3
3 4 1
2 3 3
3 2 2
Output
0 1 2 1 3 1 0 1
Explanation
Operation (3,4,1) places containers at . Operation (2,3,3) places them at . Operation (3,2,2) places them at . Counting selections yields ; position has three containers.