Cod sursa(job #1870511)

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

#include<iostream>

#include<fstream>

using namespace std;

int main()
{

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