记录编号 598485 评测结果 AAAAAAAAAAAAAAA
题目名称 数列操作A 最终得分 100
用户昵称 Gravatar梦那边的美好ET 是否通过 通过
代码语言 C++ 运行时间 0.909 s
提交时间 2025-01-24 16:44:58 内存使用 4.03 MiB
显示代码纯文本
#include<bits/stdc++.h>
#define maxn 100010
#define ll long long
using namespace std;
int n,m,a1,a2;
char s[10];
ll c[maxn];
ll getsum(int x){
    ll ans=0;
    for(;x;x-=x&-x)ans+=c[x];
    return ans;
}
void insert(int x){
    for(;x<=n;x+=x&-x)c[x]+=(ll)a2;
    return;
}
int main(){
    freopen("shulie.in","r",stdin);
    freopen("shulie.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a2),insert(i);
    scanf("%d",&m);
    while(m--){
        scanf("%s",s);scanf("%d%d",&a1,&a2);
        if(s[0]=='A')insert(a1);
        else printf("%lld\n",getsum(a2)-getsum(a1-1));
    }
    return 0;
}