Cod sursa(job #1470726)

Utilizator IliesiDanielDaniel IliesiDaniel Data 11 august 2015 23:51:10
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <iostream>
#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) {
            cheltuieli[a - 1] -= b;
        } else  {
            int s = 0;
            for (int j = a - 1; j < b; j++)
                s += cheltuieli[j];
            fout << s << "\n";
        }
    }

    return 0;
}