PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SGM0000061. Chmin Chmax Add và tổng đoạn (Range Chmin Chmax Add Range Sum)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chmin Chmax Add và tổng đoạn (Range Chmin Chmax Add Range Sum)
Range Chmin Chmax Add Range Sum
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer sequence , process queries on half-open ranges :
0 l r b: set for every .1 l r b: set for every .2 l r b: set for every .3 l r: print .
Input
The first line contains . The second line contains . Each of the next lines is a query of type 0, 1, 2, or 3 as described.
Output
For every type-3 query, print the range sum on its own line.
Subtasks
-
Subtask 1 (20%): N,Q≤30; all other conditions are unchanged.
-
Subtask 2 (30%): N,Q≤3000; all other conditions are unchanged.
-
Subtask 3 (50%): full constraints:
-
-
-
throughout all operations, always holds
Examples
Input
5 8
1 2 3 4 5
3 0 5
0 1 5 3
3 0 5
1 0 3 2
2 2 5 4
3 1 4
0 0 5 6
3 0 5
Output
15
12
16
22
Explanation
The first sum is 15. Chmin on [1,5) gives [1,2,3,3,3] with sum 12. After chmax and add, the array becomes [2,2,7,7,7].