Pagini recente » Cod sursa (job #1166840) | Istoria paginii home | Istoria paginii home | Rating Seulean Erik-Cristian (blexx) | Cod sursa (job #1467110)
#include <iostream>
#include <fstream>
using namespace std;
int n, m;
int zile[1001]; // Suma de bani inca neachitata pentru o comanda efectuata in ziua i
int main () {
ifstream fin;
ofstream fout;
fin.open("datorii.in");
fout.open("datorii.out");
fin >> n;
fin >> m;
for (int i = 0; i < n; i++) { fin >> zile[i + 1]; }
int tip;
int a, b;
for (int i = 0; i < m; i++) {
fin >> tip;
fin >> a;
fin >> b;
if (tip == 0) {
// Operatie de tip A
zile[a] -= b;
} else {
// Operatie de tip B
int suma = 0;
for (int j = a; j <= b; j++) { suma += zile[j]; }
fout << suma << "\n";
}
}
fin.close();
fout.close();
return 0;
}