U94691.Segment with the Maximum Sum

通过率:0%

时间限制:1.00s

内存限制:128MB

题目描述

In this problem, you need to write a segment tree to find the segment with the maximum sum.

输入格式

第一行包含两个数字 nnmm1n,m1000001\le n, m\le 100000 )。( 1n,m1000001\le n, m\le 100000 ),即数组的大小和操作次数。下一行包含 nnaia_i ,即数组的初始状态( 109ai109-10^9\le a_i \le 10^9 )。下面几行是操作说明。每个操作的说明如下: ii vv , 为索引为 ii 的元素赋值 vv0i<n0\le i < n , 109v109-10^9\le v\le 10^9 )。

输出格式

打印 m+1m+1 行:在所有操作之前和每次操作之后,某段上的最大数字总和。请注意,该数据段可能为空(因此其总和等于 0)。

输入输出样例

  • 输入#1

    5 2
    5 -4 4 3 -5
    4 3
    3 -1
    

    输出#1

    8
    11
    7
    
  • 输入#2

    4 2
    -2 -1 -5 -4
    1 3
    3 2
    

    输出#2

    0
    3
    3
    
首页