Cod sursa(job #14390)
Utilizator | Data | 8 februarie 2007 21:41:07 | |
---|---|---|---|
Problema | Datorii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include<fstream>
using namespace std;
fstream f,g;
int main()
{
long A[15001],B[15001],N,M,i,j,x,y,z,s,ok;
f.open("datorii.in",ios::in);
g.open("datorii.out",ios::out);
f>>N>>M;
B[0]=0;
for (i=1;i<=N;i++)
{
f>>A[i];
B[i]=B[i-1]+A[i];
}
ok=N+1;
for (i=1;i<=M;i++)
{
f>>x>>y>>z;
if (x==0)
{
A[y]-=z;
if (y<ok)ok=y;
}
else
{
if (ok<N+1)
{
for (j=ok;j<=N;j++) B[j]=B[j-1]+A[j];
ok=N+1;
}
g<<B[z]-B[y-1]<<endl;
}
}
g.close();
f.close();
return 0;
}