Pagini recente » Cod sursa (job #2683476) | Cod sursa (job #2479997) | Cod sursa (job #2959629) | Cod sursa (job #919921) | Cod sursa (job #409864)
Cod sursa(job #409864)
#include <fstream>
using namespace std;
#define Max 15000
#define Fin "datorii.in"
#define Fout "datorii.out"
ifstream in(Fin);
ofstream out(Fout);
int n,m,v[Max];
void citire()
{
int x;
in>>n;
in>>m;
in>>v[1];
for(int i=2;i<=n;i++)
{
in>>x;
v[i]=v[i-1]+x;
}
}
void operatii()
{
int x,y,z;
for(int i=1;i<=m;i++)
{
in>>x>>y>>z;
if(x==0)
{
for(;y<=n;y++)
v[y]-=z;
}
else
{
out<<v[z]-v[y-1]<<"\n";
}
}
}
int main(void)
{
citire();
operatii();
return 0;
}