Cod sursa(job #31218)
Utilizator | Data | 15 martie 2007 17:46:26 | |
---|---|---|---|
Problema | Datorii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.34 kb |
#include<stdio.h>
int n,m,x,y,i,ok,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;}