Cod sursa(job #799025)

Utilizator predator5047Butiu Alexandru Octavian predator5047 Data 17 octombrie 2012 19:11:10
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
//============================================================================
// Name        : Datorii.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <fstream>
#include <numeric>
using namespace std;
int n, m, v[16000];

void citire(ifstream& fin) {

	fin >> n >> m;
	for(int i = 1; i <= n; ++i)
		fin >> v[i];
}

int main() {
	ifstream fin("datorii.in");
	ofstream fout("datorii.out");
	citire(fin);
	int op, x, y;

	for(int i = 1; i <= m; ++i) {
		fin >> op >> x >> y;
		if(op == 0)
			v[x] -= y;
		else
			fout << accumulate(v + x, v + y + 1, 0) << '\n';
	}

	return 0;
}