Cod sursa(job #31205)
Utilizator | Data | 15 martie 2007 17:35:46 | |
---|---|---|---|
Problema | Datorii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#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",&a[i]);
for(;m;m--)
{scanf("%d %d %d",&ok,&x,&y);
if(!ok) {a[x]=a[x]-y;continue;}
s=0;
for(i=x;i<=y;i++)
s=s+a[i];
printf("%d\n",s);
}
return 0;}