#P4513. 小白逛公园
小白逛公园
Description
Near Xiaoxin’s home there is a “Park Road,” along one side of which parks are lined up from south to north. Xiaobai is dazzled and is not sure which parks to visit.
At the beginning, Xiaobai assigns a score to each park based on its scenery. For convenience, every time they go for a walk, Xiaoxin specifies a range, and Xiaobai may choose a contiguous sequence of parks between the -th and -th parks (inclusive). Of course, Xiaobai wants the sum of the selected parks’ scores to be as large as possible. Meanwhile, as some parks’ landscapes change, Xiaobai’s scores may also change.
So please help Xiaobai choose the parks.
Input Format
- The first line contains two integers and , representing the number of parks and the total number of operations (walks or score changes).
- The next lines each contain one integer, giving the initial score that Xiaobai assigns to each park in order.
- The next lines each contain three integers. The first integer is or .
- If , Xiaoxin is taking Xiaobai out to play. The next two integers and give the selectable range of parks . The testdata may contain cases where , in which case you should swap them.
- If , Xiaobai changes the score of a park. The next two integers and mean the score of the -th park becomes .
Output Format
For each walk, output one line containing a single integer: the maximum possible sum of scores of the parks Xiaobai can select.
5 3
1
2
-3
4
5
1 2 3
2 2 -1
1 2 3
2
-1
Hint
Constraints
For of the testdata, , , and all scores are integers with absolute value at most .
Translated by ChatGPT 5
京公网安备 11011102002149号