Pagini recente » infoarena - comunitate informatica, concursuri de programare | Cod sursa (job #2456385) | Cod sursa (job #2669819) | Cod sursa (job #2269970) | Cod sursa (job #2569071)
#include <fstream>
using namespace std;
ifstream fin ("datorii.in");
ofstream fout ("datorii.out");
int n,m,i,j,s,v[15004],a,b,c;
int main()
{
fin>>n>>m;
for(i=1; i<=n; i++)
fin>>v[i];
for(i=1; i<=m; i++)
{
fin>>a>>b>>c;
s=0;
if(a==0)
v[b]=v[b]-c;
else
{
for(j=b; j<=c; j++)
s=s+v[j];
}
if(s!=0)
fout<<s<<endl;
}
return 0;
}