PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000268. Cập nhật cấp số cộng một đoạn (Increasing 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ập nhật cấp số cộng một đoạn (Increasing Range Updates)
Increasing Range Updates
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
An array of elements is initially zero, indexed from 1. Each operation gives . Add to each for , leaving other elements unchanged. Print the array after all operations.
Input
First line: . Next lines: .
Output
Print integers on one line.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; for all operations.
- Subtask 3 (50 points): ; ; .
Example 1
Input
5 2
2 4
3 5
Output
0 1 3 5 3
Explanation
After the first operation: 0 1 2 3 0; the second adds 0 0 1 2 3.
Example 2
Input
3 2
1 3
3 3
Output
1 2 4
Explanation
Add 1 2 3, then add one more at position 3.