PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000252. Cộng cấp số cộng trên đoạn (Arithmetic Progression Range Addition)
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 cấp số cộng trên đoạn (Arithmetic Progression Range Addition)
Arithmetic Progression Range Addition
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Initially contains zeros indexed from 1. Perform operations : add to positions through respectively. Other positions stay unchanged. may be negative or zero. Print the final array.
Input
First line: . Each of the next lines contains .
Output
Print integers on one line, separated by spaces.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Example 1
Input
5 2
2 4 3
1 3 -2
Output
-2 -1 0 9 0
Explanation
After operation 1: [0,3,6,9,0]. Operation 2 adds −2,−4,−6 to the first three cells.
Example 2
Input
1 2
1 1 5
1 1 -5
Output
0
Explanation
The two operations cancel.