Cod sursa(job #14210)

Utilizator pitradaPit-Rada Ionel-Vasile pitrada Data 8 februarie 2007 14:25:57
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include<fstream>
using namespace std;
fstream f,g;

long A[15001],N,M,i,j,x,y,z;
int main()
{
f.open("datorii.in",ios::in);
g.open("datorii.out",ios::out);

f>>N>>M;
A[0]=0;
for (i=1;i<=N;i++)
  {
  f>>x;
  A[i]=A[i-1]+x;
  }
for (i=1;i<=M;i++)
  {
  f>>x>>y>>z;
  if (x==0) 
     {
     for (j=y;j<=N;j++)
        A[j]-=z;
     }
     else
     {
     g<<A[z]-A[y-1]<<endl;
     }
  }


g.close();
f.close();
return 0;
}