Problem7409--GSS9 - Can you answer these queries IX

7409: GSS9 - Can you answer these queries IX

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

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) (lx1y1 < x2y2 < ... < xtytrtk) 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 

HINT

题目来源:SPOJ GSS9

Source/Category