Cod sursa(job #31210)
Utilizator | Data | 15 martie 2007 17:39:54 | |
---|---|---|---|
Problema | Datorii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<stdio.h>
int n,m,x,y,i,j,ok,s,a[15001],b[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) {b[x]=-y; b[0]=x>b[0]?x:b[0];continue;}
s=a[y]-a[x];
for(i=x;i<=b[0];i++)
s=s+b[i];
printf("%d\n",a[y]-a[x]);
}
return 0;}