Pagini recente » Cod sursa (job #1137831) | Cod sursa (job #2734314) | infoarena - comunitate informatica, concursuri de programare | Cod sursa (job #2077673) | Cod sursa (job #2284747)
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream fin("datorii.in");
ofstream fout("datorii.out");
long n, m, A[15000], i, j, k, l,s;
fin>>n>>m;
for (i=1;i<=n;i++)
fin>>A[i];
for(i=1;i<=m;i++)
{ fin>>j;
if (j==1)
{ fin>>k>>l; s=0;
for (k; k<=l;k++)
s+=A[k];
fout<<s<<endl;
}
else
{ fin>>k>>l;
A[k]=A[k]-l;
}
}
fin.close();
fout.close();
return 0;
}