Pagini recente » Cod sursa (job #1618296) | Cod sursa (job #1123755) | Cod sursa (job #1285447) | Cod sursa (job #585958) | Cod sursa (job #693025)
Cod sursa(job #693025)
#include<fstream>
#define Nmax1 15000
#define Nmax2 100000
using namespace std;
int n,m,M[Nmax2][3];
int V[Nmax1];
int S[Nmax1];
ifstream f("datorii.in");
ofstream g("datorii.out");
void citesc()
{
f>>n>>m;
for(int i=1;i<=n;i++)
f>>V[i];
for(int i=1;i<=m;i++)
for(int j=1;j<=3;j++)
f>>M[i][j];
}
void rezolv()
{
citesc();
int i,j,nr=0;
for(i=1;i<=m;i++)
{
if(M[i][1]==1)
{
nr++;
for(j=M[i][2];j<=M[i][3];j++)
S[nr]+=V[j];
}
else
{
V[M[i][2]]-=M[i][3];
}
}
for(i=1;i<=nr;i++)
g<<S[i]<<endl;
}
int main()
{
rezolv();
f.close();
g.close();
return 0;
}