Pagini recente » Rating Ababei Robert-Petronel (AbRobert) | Cod sursa (job #482247) | Profil stoicaandrei | Cod sursa (job #1513814) | Cod sursa (job #1146372)
#include<cstdio>
#define ub(x) (x&(-x))
#define lung unsigned long long
using namespace std;
lung AIB[20000],x,X,Y,k,S,N,M;
inline lung Qwerry(lung x)
{
lung S=0;
for (int i=x;i>0;i-=ub(i)) S+=AIB[i];
return S;
}
inline void Update(lung x,lung NR)
{
for (int i=x;i<=N;i+=ub(i)) AIB[i]+=NR;
}
int main()
{
freopen("datorii.in","r",stdin);
freopen("datorii.out","w",stdout);
scanf("%d%d",&N,&M);
for (int i=1;i<=N;++i) scanf("%lld",&x), Update(i,x);
for (int i=1;i<=M;++i)
{
scanf("%lld%lld%lld",&k,&X,&Y);
if (k==0) Update(X,-Y);
else
{
S=Qwerry(Y)-Qwerry(X-1);
printf("%d\n",S);
}
}
fclose(stdin); fclose(stdout);
return 0;
}