Pagini recente » Cod sursa (job #1423327) | Cod sursa (job #31116) | Cod sursa (job #3250072) | Cod sursa (job #27012) | Cod sursa (job #31216)
Cod sursa(job #31216)
#include<stdio.h>
int n,m,x,y,i,j,ok,s,a[15001],b[15002];
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];b[15001]=x<b[15001]?x:b[15001];continue;}
s=a[y]-a[x];
for(i=x>b[15001]?x:b[15001];i<=b[0]&&i<y;i++)
s=s+b[i];
printf("%d\n",s);}
return 0;}