From 85dd254b3b19d92ced4cd1eac29a6efbcc7684dc Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Tue, 22 Sep 2026 19:37:38 +0800 Subject: [PATCH] new file: P3374.cpp --- P3374.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 P3374.cpp diff --git a/P3374.cpp b/P3374.cpp new file mode 100644 index 0000000..c510fd2 --- /dev/null +++ b/P3374.cpp @@ -0,0 +1,34 @@ +#include +using namespace std; +int n,m; +long long tree[500005]; +long long a[500005]; +int lowbit(int n){ + return n&(-n); +} +void modify(int x,long long k) +{ + for(;x<=n;x+=lowbit(x)) + tree[x]+=k; +} +long long query(int x){ + int ans; + for(;x;x-=lowbit(x)) + ans=ans+tree[x]; + return ans; +} +int main(){ + scanf("%d%d",&n,&m); + for(int i=1;i<=n;++i){ + scanf("%lld",&a[i]); + modify(i,a[i]); + } + while(m--){ + int op,x; + long long y; + scanf("%d%d%lld",&op,&x,&y); + if(op==1) modify(x,y); + else printf("%lld\n",query(y)-query(x-1)); + } + return 0; +} \ No newline at end of file