Cod sursa(job #1870447)

Utilizator omnipedPopescu Octavian omniped Data 6 februarie 2017 17:37:36
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>

using namespace std;

int main()
{
	int N, M, k, SumaInterogare, x, y, z;
	ifstream fin("C:\\Users\\Danut\\Desktop\\in.txt");
	ofstream fout("C:\\Users\\Danut\\Desktop\\out.txt");
	vector<double>myvector;
	fin >> N >> M;
	for (auto i = 0;i < N;i++)
	{
		fin >> k;
		myvector.push_back(k);
	}

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