Cod sursa(job #135013)
| Utilizator | Data | 12 februarie 2008 20:08:42 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include<stdio.h>
int c[15010];
int main()
{ freopen("datorii.in","r",stdin);
freopen("datorii.out","w",stdout);
int n,m,x,y,op,i,j;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
{ scanf("%d",&x);
j=i;
while(j<=n)
{ c[j]+=x;
j+=(j^(j-1))&j;
}
}
for(i=1;i<=m;i++)
{ scanf("%d%d%d",&op,&x,&y);
if(op)
printf("%d\n",c[y]-c[x-1]);
else { j=x;
while(j<=n)
{ c[j]-=y;
j+=(j^(j-1))&j;
}
}
}
printf("\n");
return 0;
}