Pagini recente » Cod sursa (job #3289837) | Cod sursa (job #1287883) | Cod sursa (job #1381515) | Cod sursa (job #3207754) | Cod sursa (job #31217)
Cod sursa(job #31217)
#include<stdio.h>
int n,m,x,y,i,j,ok,s,a[15001];
int main()
{freopen("datorii.in","r",stdin);
freopen("datorii.out","w",stdout);
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++)
{scanf("%d",&x);
a[i]=a[i-1]+x;}
for(;m;m--)
{scanf("%d %d %d",&ok,&x,&y);
if(!ok) {for(i=x;i<=n;i++) a[i]=a[i]-y;continue;}
printf("%d\n",a[y]-a[x]);}
return 0;}