Cod sursa(job #1470897)
Utilizator | Data | 12 august 2015 16:46:30 | |
---|---|---|---|
Problema | Datorii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <fstream>
#include <vector>
using namespace std;
ofstream fout ("datorii.out");
ifstream fin ("datorii.in");
int main() {
vector <int> cheltuieli;
int n, m, op, a, b;
fin >> n >> m;
for (int i = 0; i < n; i++) {
fin >> op;
cheltuieli.push_back(op);
}
for (int i = 0; i < m; i++) {
fin >> op >> a >> b;
if (!op) {
for (int j = a - 1; j < n; j++)
cheltuieli[j] -= b;
} else {
fout << cheltuieli[b - 1] - cheltuieli[a - 1] << "\n";
}
}
return 0;
}