Cod sursa(job #1248144)

Utilizator AndreiiacobIacob Andrei Constantin Andreiiacob Data 24 octombrie 2014 18:45:41
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
// ConsoleApplication5.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <fstream>
using namespace std;
ifstream fin ("datorii.in");
ofstream fout ("datorii.out");

int _tmain(int argc, _TCHAR* argv[])
{
	int n, m, x, y, i, s, v[100];
		fin >> n;
	fin >> m;
	for (i = 0; i < n; n++)
		fin >> v[i];
	while (fin>>i)
	if (i)
	{
		fin >> x;
		fin >> y;
		s = 0;
		for (i = x; i <= y; i++)
			s += v[i];
		fout << s << endl;
	}
	else {
		fin >> x;
		fin >> y;
		v[x - 1] -= y;
		if (v[x - 1]<0)
			v[x - 1] = 0;
	}
	fin.close();
	fout.close();
	return 0;
}