PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SGM0000012. Truy vấn tổng đoạn con lớn nhất III (Can you answer these queries III)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Truy vấn tổng đoạn con lớn nhất III (Can you answer these queries III)
Can you answer these queries III
Source: SPOJ
Version: Phuoc Hung OJ Extended
Given an array , process two operations:
0 x y: assign .1 x y: print the maximum sum of a non-empty contiguous subarray inside .
Input
The first line contains .
The second line contains the array.
The third line contains .
The next lines describe the operations.
Output
For every operation of type 1, print the answer on its own line.
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , .
Examples
Input
4
1 2 3 4
4
1 1 3
0 3 -3
1 2 4
1 3 3
Output
6
4
-3
Explanation
The sample follows the operations exactly; each printed line corresponds to a query that requires output.