Cod sursa(job #3338861)

Utilizator bulatalexandrinaAlexandrina Bulat bulatalexandrina Data 5 februarie 2026 12:14:02
Problema Datorii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <bits/stdc++.h>
using namespace std;
long long A[15000];
int main() {
    ifstream cin("datorii.in");
    ofstream cout("datorii.out");
    int N, M;
    cin >> N >> M;
    for (int i = 0; i <= N; i++)
        cin >> A[i];
    while (M--) {
        int tip, x, y;
        cin >> tip >> x >> y;
        if (tip == 0) {
            A[x] -= y;  
        } else {
            long long s = 0;
            for (int i = x; i <= y; i++)
                s += A[i];
            cout << s << '\n'; } }
    return 0; }