#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define _zero(a) memset(a, 0, sizeof(a))
#define _far(a) memset(a, 0x3f,sizeof (a))
#define __far(a) memset(a, -0x3f,sizeof (a))
#define far 0x3f3f3f3f
#define endl '\n'
#define int long long
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define rep(a,b,c) for(int (a) = (b);(a)<=(c);(a)++)
#define per(a,b,c) for(int (a)=(b);(a)>=(c);(a)--)
#define sqr(a) (a)*(a)
#define VI vector<int>
#define VII vector<vector<int>>
#define pb push_back
#define PII pair<int,int>
typedef long long ll;
typedef double dd;
typedef long double ld;
using namespace std;
const int inf = 1e10;
const int M = 998244353;
const int maxn = 2e5 + 1000;
const ld pi = atan2(0, -1);//arctan(y/x);
const ld eps = 1e-4;
const int N=1e5+100;
int n,m;
int a[N];
int b[N];
int ask(int x)
{
int ans=0;
for(;x;x-=x&-x)ans+=b[x];
return ans;
}
void add(int x,int y)
{
for(;x<=n;x+=x&-x)b[x]+=y;
}
signed main()
{
IOS;
cin>>n>>m;
rep(i,1,n)cin>>a[i];
_zero(b);
while(m--)
{
char s;
int l,r,t;
cin>>s;
if(s=='C')
{
cin>>l>>r>>t;
add(l,t);
if(r+1<=n)add(r+1,-t);
}
else
{
cin>>l;
int k=ask(l);
cout<<k+a[l]<<endl;
}
}
return 0;
}
acwing 242
最新推荐文章于 2024-11-11 20:40:17 发布