Cod sursa(job #915584)
#include <stdio.h>
#define nmax 15001
using namespace std;
int arb[3*nmax+66], N;
void update(int x, int v)
{
for (; x <= N; x += x^(x-1) & x)
arb[x] += v;
}
int query(int x)
{
int r = 0;
for (; x; x -= x ^ (x-1) & x)
r += arb[x];
return r;
}
int main() {
freopen ("datorii.in", "r", stdin);
freopen ("datorii.out", "w", stdout);
int M, i, opt, a, b;
scanf ("%d %d", &N, &M);
for (i = 1; i <= N; ++i) {
scanf ("%d", &opt);
update (i, opt);
}
while (M) {
--M;
scanf ("%d %d %d", &opt, &a, &b);
if (opt) printf ("%d\n", query (b) - query (a-1));
else update (a, -b);
}
return 0;
}