#SGM0000013. Truy vấn tổng tiền tố (Prefix Sum Queries)
Truy vấn tổng tiền tố (Prefix Sum Queries)
Prefix Sum Queries
Source: CSES
Version: Phuoc Hung OJ Extended
Given an array of integers, process queries:
1 k u: assign .2 a b: find the maximum prefix sum inside the range . The empty prefix with sum is allowed.
Thus a type 2 query asks for:
Input
The first line contains .
The second line contains .
The next lines contain the queries.
Output
Print the answer for every type 2 query.
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , .
Examples
Input
8 4
1 2 -1 3 1 -5 1 4
2 2 6
1 4 -2
2 2 6
2 3 4
Output
5
2
0
Explanation
The sample follows the operations exactly; each printed line corresponds to a query that requires output.