Cod sursa(job #1870488)

Utilizator omnipedPopescu Octavian omniped Data 6 februarie 2017 18:10:15
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb



#include<fstream>

using namespace std;

int main()
{

	int N, M, SumaInterogare, x, y, z,*ptr=0;
	ifstream fin("datorii.in");
	ofstream fout("datorii.out");
	
	fin >> N >> M;
	for (auto i = 0;i < N;i++)
	{
		ptr = new int[N];
		fin >> ptr[i];
		
	}

	for (auto i = 0;i < M;i++)
	{
		SumaInterogare = 0;
		fin >> x >> y >> z;
		if (x == 0)
			ptr[y-1] = ptr[y-1] - z;
		if (x == 1)
		{
			for (auto j = y - 1;j <= z - 1;j++)
				SumaInterogare = SumaInterogare + ptr[j];
			    fout << SumaInterogare << endl;
		}
	}
	delete ptr;
}