Cod sursa(job #1325034)

Utilizator EhtRalpmetFMI Ardei Claudiu-Alexandru EhtRalpmet Data 23 ianuarie 2015 09:40:54
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <fstream>

using namespace std;
ifstream cin("datorii.in");
ofstream cout("datorii.out");

int s,n,m,i,j,a[15001],x,y,q;
int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    for(j=1;j<=m;j++){
        cin>>q;
        if(q==0){
            cin>>x>>y;
            a[x]-=y;
        }
        else{
            cin>>x>>y;
            s=0;
            for(i=x;i<=y;i++){
                s+=a[i];
            }
            cout<<s<<'\n';
        }
    }
    return 0;
}