PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000273. Cộng hàm tuyến tính trên đoạn (Linear Function Range Updates)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Cộng hàm tuyến tính trên đoạn (Linear Function Range Updates)
Linear Function Range Updates
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
An array of length is initially zero and indexed from 1. Each update adds to for all . Here is the absolute array index, not an offset from . Print the final array.
Input
First line: . Next lines: .
Output
Print integers on one line.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; for every update.
- Subtask 3 (50 points): ; ; .
Example 1
Input
5 2
1 3 1 0
2 5 -1 4
Output
1 4 4 0 -1
Explanation
First array: . Second update adds at indices 2 through 5.
Example 2
Input
3 2
3 3 2 -1
1 3 0 -2
Output
-2 -2 3
Explanation
Index 3 receives 5, then every index decreases by 2.