题目链接
http://noi-test.zzstep.com/contest/0x40%E3%80%8C%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E8%BF%9B%E9%98%B6%E3%80%8D%E4%BE%8B%E9%A2%98/4301%20Can%20you%20answer%20on%20these%20queries%20III
分析
线段树节点记录区间和,左端最大连续和,右端最大连续和及区间最大连续和;
合并时最大连续和可由其余信息推出。
AC代码
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
inline int read() {
int num = 0, flag = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') flag = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
num = num * 10 + c - '0', c = getchar();
return flag * num;
}
const int maxn = 5e5 + 5;
struct SegmentTree {
int l, r, sum, lmax, rmax, maxs;
SegmentTree operator + (const SegmentTree& rhs