Pagini recente » Cod sursa (job #2148399) | Cod sursa (job #2224233) | Cod sursa (job #1617240) | Cod sursa (job #514960) | Cod sursa (job #2536263)
#include <bits/stdc++.h>
using namespace std;
#define zeros(x) ((x ^ (x - 1)) & x)
ifstream f("datorii.in");
ofstream g("datorii.out");
typedef unsigned long long unll;
unll n,m;
unll AIB[15001];
void Add(unll pos,unll quantity)
{
for(int i = pos;i <= n;i += zeros(i))
AIB[i] += quantity;
}
unll Query(unll pos)
{
unll sum = 0;
for(int i = pos;i > 0;i -= zeros(i))
sum += AIB[i];
return sum;
}
void Read()
{
unll x;
unll type, a, b;
f>>n>>m;
for(int i = 1;i <= n;++i)
{
f>>x;
Add(i, x);
}
for(int i = 1;i <= m;++i)
{
f>>type>>a>>b;
switch(type)
{
case 0:
Add(a, -b);
break;
case 1:
g<<Query(b) - Query(a - 1)<<'\n';
break;
}
}
f.close();
g.close();
}
int main()
{
Read();
return 0;
}