Cod sursa(job #1758005)

Utilizator iaexenAlex Radu iaexen Data 16 septembrie 2016 11:24:35
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <fstream>
double a[15000];
using namespace std;
int main()
{
    int n,m,t,v,p,q,i,x,j,s;
    ifstream f("datorii.in");
    ofstream g("datorii.out");
    f>>n>>m;
    for(i=1;i<=n;i++)
        {f>>a[i];
        }
    for(i=1;i<=m;i++)
    {
       f>>x;
       if(x==0)
        {f>>t>>v;
        a[t]=a[t]-v;
        }
        else
        {
            f>>p>>q;
            s=0;
            for(j=p;j<=q;j++)
                s=s+a[j];
            g<<s<<'\n';
        }
    }
    return 0;
}