Cod sursa(job #1241195)

Utilizator ovidiu01Costea Ovidiu Tudor ovidiu01 Data 12 octombrie 2014 22:30:08
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <fstream>
#include <iostream>

using namespace std;

int main()
{
	struct datorie{
		int b, t, v;
	}x[100];
	
	int a[100], i, j, n, m, s;
	
	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();
}