7409: GSS9 - Can you answer these queries IX
[Creator : ]
Description
Consider integer sequence a1, a2, ..., an. You should run queries of two types:
- The query format is "0 i val". In reply to this query you should make the following assignment: ai = val.
- The query format is "1 l r k". In reply to this query you should print the maximum sum of exactly k non-intersecting subsegments of sequence al, al + 1, ..., ar. Formally, you should choose exactly k pairs of integers (x1, y1), (x2, y2), ..., (xt, yt) (l ≤ x1 ≤ y1 < x2 ≤ y2 < ... < xt ≤ yt ≤ r; t ≤ k) such that the sum ax1 + ax1 + 1 + ... + ay1 + ax2 + ax2 + 1 + ... + ay2 + ... + axt + axt + 1 + ... + aytis as large as possible.
Sample 1 Input
2
-1 -1
1
1 1 2 2
Sample 1 Output
-2