Pagini recente » Cod sursa (job #849035) | Cod sursa (job #2624233) | Cod sursa (job #893289) | Cod sursa (job #1471944) | Cod sursa (job #2869560)
#include <fstream>
#include <string>
#include <cstring>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#define Nmax 100001
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
const int oo = 1 << 28;
typedef vector < int > VI;
int aib[Nmax];
int n, m, op ,x, y;
void Update(int pos, int x){
for(int i = pos; i < Nmax; i += i & -i)
aib[i] += x;
}
int Query(int pos){
int ans = 0;
for(int i = pos; i > 0; i -= i & -i)
ans += aib[i];
return ans;
}
int main() {
fin >> n >> m;
for(int i = 1; i <= n; ++i){
fin >> x;
Update(i, x);
}
for(int i = 1; i <= m; ++i){
fin >> op >> x >> y;
if(!op)
Update(x, -y);
else fout << Query(y) - Query(x - 1) << "\n";
}
return 0;
}