Pagini recente » Cod sursa (job #2705978) | Cod sursa (job #2698216) | Cod sursa (job #450512) | Cod sursa (job #1485782) | Cod sursa (job #31222)
Cod sursa(job #31222)
#include<stdio.h>
int n,m,a[15001];
short int x,y,i,ok;
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("%sd %sd %sd",&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;}