1 Star 0 Fork 0

Fropised / nlogn数据结构

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
树状数组 371 Bytes
一键复制 编辑 原始数据 按行查看 历史
Fropised 提交于 2017-11-09 19:11 . luoguR4474007
#include<cstdio>
using namespace std;
typedef int L;
static const int MaxN=5*1e5+5;
L a[MaxN],n,c[MaxN],m,i,t,T,x,y,r;
L A(L p,L t){for(;p<=n;p+=p&-p)c[p]+=t;}
L P(L p){for(r=0;p;p-=p&-p)r+=c[p];return r;}
main(){
scanf("%d%d",&n,&m);
for(i=1;i<=n;++i)scanf("%d",&t),A(i,t);
for(i=0;i<m;++i)scanf("%d%d%d",&T,&x,&y),T==1?A(x,y):printf("%d\n",P(y)-P(x-1));
}
C++
1
https://gitee.com/Fropised/nlogn.git
git@gitee.com:Fropised/nlogn.git
Fropised
nlogn
nlogn数据结构
master

搜索帮助