Cod sursa(job #1283570)

Utilizator ovidiu01Costea Ovidiu Tudor ovidiu01 Data 5 decembrie 2014 20:39:56
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <fstream>
#include <iostream>

using namespace std;

int main()
{
	struct datorie{
		int b, t, v;
	};
	
	datorie *x = new datorie[100001];
	
	int a[15001], n, s;
	
	long m, i, j;
	
	ifstream fin;
	ofstream fout;
	fin.open("datorii.in");
	fout.open("datorii.out");
	fin >> n >> m;
	for( i = 1; i <= n; i++ )
		fin >> a[i];
	for(j = 1; j <= m; j++ )
	{
		
		fin >> x[j].b >> x[j].t >> x[j].v;
		if( x[j].b == 0 )	
			a[x[j].t] = a[x[j].t] - x[j].v;
		else
		{	
			s=0;
			for( i = x[j].t; i <= x[j].v; i ++ )
					s = s + a[i];
			fout << s << endl;	
		}
	}

	fin.close();
	fout.close();

	return 0;
}