This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include<bits/stdc++.h>
usingnamespacestd;
constintN=100010;
intn,m;
inta[N];
// 树状数组模板
typedeflonglongLL;
#define lowbit(x) (x & -x)
intc[N];
voidadd(intx,intd){
for(inti=x;i<N;i+=lowbit(i))c[i]+=d;
}
LLsum(intx){
LLres=0;
for(inti=x;i;i-=lowbit(i))res+=c[i];
returnres;
}
intmain(){
scanf("%d %d",&n,&m);
for(inti=1;i<=n;i++)scanf("%d",&a[i]);
// 方法1:也可以这么做,但是方法比较笨拙
// 树状数组初始化,保存差分值
// for (int i = 1; i <= n; i++) add(i, a[i] - a[i - 1]);