Pagini recente » Cod sursa (job #1048215) | Cod sursa (job #2630392) | Cod sursa (job #2060340) | Cod sursa (job #1840199) | Cod sursa (job #2784954)
#include<fstream>
using namespace std;
int n,m,x,y,s,t[15001];
bool c;
ifstream f("datorii.in");
ofstream o("datorii.out");
int main()
{
for(f>>n>>m,y=1;y<=n;++y)
for(f>>x,s=y;s<=n;t[s]+=x,s+=(s&-s));
while(m--) {
f>>c>>x>>y;
if(c) {
for(s=0;y;s+=t[y],y-=(y&-y));
for(--x;x;s-=t[x],x-=(x&-x));
o<<s<<'\n';
} else
for(;x<=n;t[x]-=y,x+=(x&-x));
}
return 0;
}