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.
输入格式
第一行包含两个数字 n 和 m ( 1≤n,m≤100000 )。( 1≤n,m≤100000 ),即数组的大小和操作次数。下一行包含 n 和 ai ,即数组的初始状态( −109≤ai≤109 )。下面几行是操作说明。每个操作的说明如下: i v , 为索引为 i 的元素赋值 v (0≤i<n , −109≤v≤109 )。
输出格式
打印 m+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