题目链接
https://www.acwing.com/problem/content/1266/
思路虽然这题可以用树状数组或者不带lazy标记的线段树做,但是我写了带 lazy
标记的线段树做,并且封装成了一个结构体,方便以后写线段树的题目,详情可以参考下面的代码,因为题目比较简单,就不多赘述了
#include
#include
#include
using namespace std;
#define ll long long
const int N = 1e5+10;
ll a[N];
struct Tnode{
ll l,r,sum,lazy;
};
struct SegmentTree{
Tnode tree[N
关注
打赏