Pagini recente » Clasamentul arhivei de probleme | Cod sursa (job #875608) | Cod sursa (job #884810) | Cod sursa (job #2909579) | Cod sursa (job #2784510)
#include<fstream>
using namespace std;
int n,m,x,y,j,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,j=y;j<=n;j+=(j&-j))
t[j]+=x;
while(m--) {
f>>c>>x>>y;
if(c) {
for(s=0,j=y;j;s+=t[j],j-=(j&-j));
for(j=x-1;j;s-=t[j],j-=(j&-j));
o<<s<<'\n';
} else
for(j=x;j<=n;t[j]-=y,j+=(j&-j));
}
return 0;
}