PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000244. Thực hiện hàng loạt thao tác cộng đoạn (Greg and Array)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Thực hiện hàng loạt thao tác cộng đoạn (Greg and Array)
Greg and Array
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
An array of nonnegative integers is given, together with numbered operations. Operation increases every element in its inclusive interval by . Each of requests executes each numbered operation from through once. Operations may be executed repeatedly by different requests. Print the final array.
Input
First line: . Second line: values . The next lines contain , followed by lines containing .
Output
Print the final array on one line.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; ; for every request.
- Subtask 3 (50 points): ; ; ; .
Example 1
Input
3 3 3
1 2 3
1 2 1
1 3 2
2 3 4
1 2
1 3
2 3
Output
9 18 17
Explanation
The operations occur 2,3,2 times. Add [2,2,0], [6,6,6], [0,8,8] to the initial array.
Example 2
Input
1 1 1
1
1 1 1
1 1
Output
2
Explanation
The only operation adds 1 to the only element.
Example 3
Input
4 3 6
1 2 3 4
1 2 1
2 3 2
3 4 4
1 2
1 3
2 3
1 2
1 3
2 3
Output
5 18 31 20
Explanation
Operation counts are 4,6,4; element increases are 4,16,28,16.