Pagini recente » Cod sursa (job #2369129) | Cod sursa (job #281248) | Cod sursa (job #1687770) | Cod sursa (job #2600447) | Cod sursa (job #1448573)
#include<fstream>
using namespace std;
ifstream f("datorii.in"); ofstream g("datorii.out");
int n,nr,AIB[15010];
inline int zero(int x) {return (-x)&x;}
void update(int poz, int val)
{ for(;poz<=n;poz+=zero(poz)) AIB[poz]+=val;}
int calc(int poz)
{ int s=0;
for(;poz;poz-=zero(poz)) s+=AIB[poz];
return s;
}
int main()
{ f>>n>>nr;
for(int x,i=1;i<=n;++i) {f>>x; update(i,x);}
while(nr--)
{ int t,x,y;
f>>t>>x>>y;
if(t) g<<calc(y)-calc(x-1)<<"\n"; else update(x,-y);
}
return 0;
}