Cod sursa(job #916504)

Utilizator addy01adrian dumitrache addy01 Data 16 martie 2013 16:37:34
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <iostream>
#include <cstdio>
using namespace std;
    int n,m,v[15010],a[100010][3];
int main()
{
    freopen("datorii.in","r",stdin);
    freopen("datorii.out","w",stdout);

    int i,j,s;

    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%d",&v[i]);
    for(i=1;i<=m;i++)

    {
        scanf("%d",&a[i][1]);
        scanf("%d",&a[i][2]);
        scanf("%d",&a[i][3]);
        if(a[i][1]==0)
                v[a[i][2]]=v[a[i][2]]-a[i][3];
        else
            {
                s=0;
                for(j=a[i][2];j<=a[i][3];j++)
                    s+=v[j];
               printf("%d\n",s);
            }
    }
    return 0;
}